Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-01-03 09:07:26
Exec Total Coverage
Lines: 1717 3955 43.4%
Functions: 125 338 37.0%
Branches: 923 2722 33.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 15 void load_game_configs()
279 {
280 15 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 15 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 15 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 15 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 15 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 15 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 15 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 15 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 15 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 15 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 15 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 15 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 15 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 15 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 15 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 15 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 15 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 15 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 15 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 15 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 15 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 15 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 15 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 15 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 15 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 15 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 15 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 15 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 15 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 15 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 15 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 15 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 15 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 15 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 15 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 15 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 15 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 15 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 15 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 15 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 15 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 15 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 15 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 15 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 15 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 15 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 15 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 15 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 15 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 15 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 15 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 15 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 15 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 15 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 15 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 15 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 15 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 15 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 15 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 15 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 15 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 15 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 15 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 15 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 15 title_version = zc_get_config(cfg_sect,"title",2);
360 15 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 15 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 15 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 15 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 15 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 15 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 15 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 15 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 15 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 15 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 //workaround for the 100% CPU bug. -Gleeok
377 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
378 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
379 #else
380 15 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
381 #endif
382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 frame_rest_suggest = zc_min(2, frame_rest_suggest);
383
384 15 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
385
386 #ifdef _WIN32
387 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
388 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
389 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
390 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
391
392 // This one's for Aero
393 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
394
395 // And this one fixes patches unloading on some MIDI setups
396 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
397 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
398 #else //UNIX
399 15 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
400 15 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
401 15 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
402 #endif
403 15 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
404
405 15 char const* default_path = "";
406 15 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
407
408
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(strlen(qstdir)==0)
409 {
410 15 getcwd(qstdir,2048);
411 15 fix_filename_case(qstdir);
412 15 fix_filename_slashes(qstdir);
413 15 put_backslash(qstdir);
414 15 }
415 else
416 {
417 chop_path(qstdir);
418 }
419
420 15 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
421 15 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
422 15 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
423 15 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
424 15 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
425 15 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
426 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
427 15 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
428 15 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
429 15 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
430 15 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
431 15 }
432
433 void save_control_configs(bool kb)
434 {
435 if(kb)
436 {
437 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
438 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
439 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
440 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
441
442 if (!replay_is_replaying())
443 {
444 zc_set_config(ctrl_sect,"key_a",Akey);
445 zc_set_config(ctrl_sect,"key_b",Bkey);
446 zc_set_config(ctrl_sect,"key_s",Skey);
447 zc_set_config(ctrl_sect,"key_l",Lkey);
448 zc_set_config(ctrl_sect,"key_r",Rkey);
449 zc_set_config(ctrl_sect,"key_p",Pkey);
450 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
451 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
452 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
453 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
454 zc_set_config(ctrl_sect,"key_up", DUkey);
455 zc_set_config(ctrl_sect,"key_down", DDkey);
456 zc_set_config(ctrl_sect,"key_left", DLkey);
457 zc_set_config(ctrl_sect,"key_right",DRkey);
458 }
459 }
460 else
461 {
462 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
463 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
464 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
465 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
466 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
467 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
468 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
469 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
470 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
471 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
472 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
473 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
474 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
475 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
476
477 zc_set_config(ctrl_sect,"btn_a",Abtn);
478 zc_set_config(ctrl_sect,"btn_b",Bbtn);
479 zc_set_config(ctrl_sect,"btn_s",Sbtn);
480 zc_set_config(ctrl_sect,"btn_m",Mbtn);
481 zc_set_config(ctrl_sect,"btn_l",Lbtn);
482 zc_set_config(ctrl_sect,"btn_r",Rbtn);
483 zc_set_config(ctrl_sect,"btn_p",Pbtn);
484 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
485 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
486 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
487 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
488
489 zc_set_config(ctrl_sect,"btn_up",DUbtn);
490 zc_set_config(ctrl_sect,"btn_down",DDbtn);
491 zc_set_config(ctrl_sect,"btn_left",DLbtn);
492 zc_set_config(ctrl_sect,"btn_right",DRbtn);
493 }
494 }
495
496 void save_game_configs()
497 {
498 packfile_password("");
499
500 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
501
502 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
503 {
504 int o_window_x, o_window_y;
505 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
506 zc_set_config(cfg_sect,"window_x",o_window_x);
507 zc_set_config(cfg_sect,"window_y",o_window_y);
508 }
509
510 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
511 {
512 double monitor_scale = zc_get_monitor_scale();
513 window_width = al_get_display_width(all_get_display()) / monitor_scale;
514 window_height = al_get_display_height(all_get_display()) / monitor_scale;
515 zc_set_config(cfg_sect,"window_width",window_width);
516 zc_set_config(cfg_sect,"window_height",window_height);
517 }
518
519 zc_set_config(cfg_sect,"load_last",loadlast);
520 chop_path(qstdir);
521 zc_set_config(cfg_sect,qst_dir_name,qstdir);
522 zc_set_config("SAVEFILE","save_filename",save_file_name);
523 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
524 zc_set_config(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
525
526 flush_config_file();
527 #ifdef __EMSCRIPTEN__
528 em_sync_fs();
529 #endif
530 }
531
532 //----------------------------------------------------------------
533
534 // Timers
535
536 16416 void fps_callback()
537 {
538 16416 lastfps=framecnt;
539 16416 dword tempsecs = fps_secs;
540 16416 ++tempsecs;
541 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
542 16416 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
543 16416 ++fps_secs;
544 16416 framecnt=0;
545 16416 }
546
547 END_OF_FUNCTION(fps_callback)
548
549 15 int32_t Z_init_timers()
550 {
551 static bool didit = false;
552 const static char *err_str = "Couldn't allocate timer";
553 15 err_str = err_str; //Unused variable warning
554
555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(didit)
556 return 1;
557
558 15 didit = true;
559
560 LOCK_VARIABLE(lastfps);
561 LOCK_VARIABLE(framecnt);
562 LOCK_FUNCTION(fps_callback);
563
564
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
565 return 0;
566
567 15 return 1;
568 15 }
569
570 void Z_remove_timers()
571 {
572 remove_int(fps_callback);
573 }
574
575 //----------------------------------------------------------------
576
577 void go()
578 {
579 scare_mouse();
580 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
581 unscare_mouse();
582 }
583
584 void comeback()
585 {
586 scare_mouse();
587 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
588 unscare_mouse();
589 }
590
591 void dump_pal(BITMAP *dest)
592 {
593 for(int32_t i=0; i<256; i++)
594 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
595 }
596
597 //----------------------------------------------------------------
598
599 //Handles converting the mouse sprite from the .dat file
600 15 void load_mouse()
601 {
602 15 system_pal();
603 15 scare_mouse();
604 15 set_mouse_sprite(NULL);
605
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
606
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
75 for(int32_t j = 0; j < 4; ++j)
607 {
608 60 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
609 60 BITMAP* subbmp = create_bitmap_ex(8,16,16);
610
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(zcmouse[j])
611 destroy_bitmap(zcmouse[j]);
612 60 zcmouse[j] = create_bitmap_ex(8,sz,sz);
613 60 clear_bitmap(zcmouse[j]);
614 60 clear_bitmap(tmpbmp);
615 60 clear_bitmap(subbmp);
616 60 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
617
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 60 times.
1020 for(int32_t x = 0; x < 16; ++x)
618 {
619
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 960 times.
16320 for(int32_t y = 0; y < 16; ++y)
620 {
621 15360 int32_t color = getpixel(tmpbmp, x, y);
622
5/5
✓ Branch 0 taken 14130 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 345 times.
✓ Branch 4 taken 270 times.
15360 switch(color)
623 {
624 case dvc(1):
625 285 color = jwin_pal[jcCURSORMISC];
626 285 break;
627 case dvc(2):
628 330 color = jwin_pal[jcCURSOROUTLINE];
629 330 break;
630 case dvc(3):
631 345 color = jwin_pal[jcCURSORLIGHT];
632 345 break;
633 case dvc(5):
634 270 color = jwin_pal[jcCURSORDARK];
635 270 break;
636 }
637 15360 putpixel(subbmp, x, y, color);
638 15360 }
639 960 }
640
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(sz!=16)
641 60 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
642 else
643 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
644 60 destroy_bitmap(tmpbmp);
645 60 destroy_bitmap(subbmp);
646 60 }
647 15 set_mouse_sprite(zcmouse[0]);
648
649 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
650 15 set_palette(*hw_palette);
651 15 show_mouse(screen);
652 15 show_mouse(NULL);
653
654 15 unscare_mouse();
655 15 game_pal();
656 15 }
657
658 // sets the video mode and initializes the palette and mouse sprite
659 15 bool game_vid_mode(int32_t mode,int32_t wait)
660 {
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
662 {
663 return false;
664 }
665
666 15 scrx = (resx-320)>>1;
667 15 scry = (resy-240)>>1;
668
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
75 for(int32_t q = 0; q < 4; ++q)
669 60 zcmouse[q] = NULL;
670 15 load_mouse();
671 15 set_mouse_sprite(zcmouse[0]);
672
673
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 15 times.
255 for(int32_t i=240; i<256; i++)
674 240 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
675
676 15 set_palette(RAMpal);
677 15 clear_to_color(screen,BLACK);
678
679 15 rest(wait);
680 15 return true;
681 15 }
682
683 4 void null_quest()
684 {
685 char qstdat_string[2048];
686 4 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
687 4 strcat(qstdat_string,"#NESQST_NEW_QST");
688
689 #ifdef __EMSCRIPTEN__
690 // The quest template data file is not included because it's really big and isn't really needed
691 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
692 // which is much smaller.
693 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
694 #endif
695
696 4 byte skip_flags[4] = { 0 };
697
698 4 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
699 4 }
700
701 4 void init_NES_mode()
702 {
703 /*
704 // qst.dat may not load correctly without this...
705 QHeader.templatepath[0]='\0';
706
707 if(!init_colordata(true, &QHeader, &QMisc))
708 {
709 return;
710 }
711
712 loadfullpal();
713 init_tiles(false, &QHeader);
714 */
715 4 null_quest();
716 4 }
717
718 //----------------------------------------------------------------
719
720 qword trianglelines[16]=
721 {
722 0x0000000000000000ULL,
723 0xFD00000000000000ULL,
724 0xFDFD000000000000ULL,
725 0xFDFDFD0000000000ULL,
726 0xFDFDFDFD00000000ULL,
727 0xFDFDFDFDFD000000ULL,
728 0xFDFDFDFDFDFD0000ULL,
729 0xFDFDFDFDFDFDFD00ULL,
730 0xFDFDFDFDFDFDFDFDULL,
731 0x00FDFDFDFDFDFDFDULL,
732 0x0000FDFDFDFDFDFDULL,
733 0x000000FDFDFDFDFDULL,
734 0x00000000FDFDFDFDULL,
735 0x0000000000FDFDFDULL,
736 0x000000000000FDFDULL,
737 0x00000000000000FDULL,
738 };
739
740 word screen_triangles[28][32];
741 /*
742 qword triangles[4][16]= //[direction][value]
743 {
744 {
745 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
746 },
747 {
748 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
749 },
750 {
751 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
752 },
753 {
754 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
755 }
756 };
757 */
758
759
760 /*
761 byte triangles[4][16][8]= //[direction][value][line]
762 {
763 {
764 {
765 0, 0, 0, 0, 0, 0, 0, 0
766 },
767 {
768 1, 0, 0, 0, 0, 0, 0, 0
769 },
770 {
771 2, 1, 0, 0, 0, 0, 0, 0
772 },
773 {
774 3, 2, 1, 0, 0, 0, 0, 0
775 },
776 {
777 4, 3, 2, 1, 0, 0, 0, 0
778 },
779 {
780 5, 4, 3, 2, 1, 0, 0, 0
781 },
782 {
783 6, 5, 4, 3, 2, 1, 0, 0
784 },
785 {
786 7, 6, 5, 4, 3, 2, 1, 0
787 },
788 {
789 8, 7, 6, 5, 4, 3, 2, 1
790 },
791 {
792 8, 8, 7, 6, 5, 4, 3, 2
793 },
794 {
795 8, 8, 8, 7, 6, 5, 4, 3
796 },
797 {
798 8, 8, 8, 8, 7, 6, 5, 4
799 },
800 {
801 8, 8, 8, 8, 8, 7, 6, 5
802 },
803 {
804 8, 8, 8, 8, 8, 8, 7, 6
805 },
806 {
807 8, 8, 8, 8, 8, 8, 8, 7
808 },
809 {
810 8, 8, 8, 8, 8, 8, 8, 8
811 }
812 },
813 {
814 {
815 0, 0, 0, 0, 0, 0, 0, 0
816 },
817 {
818 15, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 14, 15, 0, 0, 0, 0, 0, 0
822 },
823 {
824 13, 14, 15, 0, 0, 0, 0, 0
825 },
826 {
827 12, 13, 14, 15, 0, 0, 0, 0
828 },
829 {
830 11, 12, 13, 14, 15, 0, 0, 0
831 },
832 {
833 10, 11, 12, 13, 14, 15, 0, 0
834 },
835 {
836 9, 10, 11, 12, 13, 14, 15, 0
837 },
838 {
839 8, 9, 10, 11, 12, 13, 14, 15
840 },
841 {
842 8, 8, 9, 10, 11, 12, 13, 14
843 },
844 {
845 8, 8, 8, 9, 10, 11, 12, 13
846 },
847 {
848 8, 8, 8, 8, 9, 10, 11, 12
849 },
850 {
851 8, 8, 8, 8, 8, 9, 10, 11
852 },
853 {
854 8, 8, 8, 8, 8, 8, 9, 10
855 },
856 {
857 8, 8, 8, 8, 8, 8, 8, 9
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 8
861 }
862 },
863 {
864 {
865 0, 0, 0, 0, 0, 0, 0, 0
866 },
867 {
868 0, 0, 0, 0, 0, 0, 0, 1
869 },
870 {
871 0, 0, 0, 0, 0, 0, 1, 2
872 },
873 {
874 0, 0, 0, 0, 0, 1, 2, 3
875 },
876 {
877 0, 0, 0, 0, 1, 2, 3, 4
878 },
879 {
880 0, 0, 0, 1, 2, 3, 4, 5
881 },
882 {
883 0, 0, 1, 2, 3, 4, 5, 6
884 },
885 {
886 0, 1, 2, 3, 4, 5, 6, 7
887 },
888 {
889 1, 2, 3, 4, 5, 6, 7, 8
890 },
891 {
892 2, 3, 4, 5, 6, 7, 8, 8
893 },
894 {
895 3, 4, 5, 6, 7, 8, 8, 8
896 },
897 {
898 4, 5, 6, 7, 8, 8, 8, 8
899 },
900 {
901 5, 6, 7, 8, 8, 8, 8, 8
902 },
903 {
904 6, 7, 8, 8, 8, 8, 8, 8
905 },
906 {
907 7, 8, 8, 8, 8, 8, 8, 8
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 8
911 }
912 },
913 {
914 {
915 0, 0, 0, 0, 0, 0, 0, 0
916 },
917 {
918 0, 0, 0, 0, 0, 0, 0, 15
919 },
920 {
921 0, 0, 0, 0, 0, 0, 15, 14
922 },
923 {
924 0, 0, 0, 0, 0, 15, 14, 13
925 },
926 {
927 0, 0, 0, 0, 15, 14, 13, 12
928 },
929 {
930 0, 0, 0, 15, 14, 13, 12, 11
931 },
932 {
933 0, 0, 15, 14, 13, 12, 11, 10
934 },
935 {
936 0, 15, 14, 13, 12, 11, 10, 9
937 },
938 {
939 15, 14, 13, 12, 11, 10, 9, 8
940 },
941 {
942 14, 13, 12, 11, 10, 9, 8, 8
943 },
944 {
945 13, 12, 11, 10, 9, 8, 8, 8
946 },
947 {
948 12, 11, 10, 9, 8, 8, 8, 8
949 },
950 {
951 11, 10, 9, 8, 8, 8, 8, 8
952 },
953 {
954 10, 9, 8, 8, 8, 8, 8, 8
955 },
956 {
957 9, 8, 8, 8, 8, 8, 8, 8
958 },
959 {
960 8, 8, 8, 8, 8, 8, 8, 8
961 }
962 }
963 };
964 */
965
966
967
968 /*
969 for (int32_t blockrow=0; blockrow<30; ++i)
970 {
971 for (int32_t linerow=0; linerow<8; ++i)
972 {
973 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
974 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
975 {
976 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
977 ++triangleline;
978 }
979 }
980 }
981 */
982
983 // the ULL suffixes are to prevent this warning:
984 // warning: integer constant is too large for "int32_t" type
985
986 qword triangles[4][16][8]= //[direction][value][line]
987 {
988 {
989 {
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL,
997 0x0000000000000000ULL
998 },
999 {
1000 0xFD00000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL,
1007 0x0000000000000000ULL
1008 },
1009 {
1010 0xFDFD000000000000ULL,
1011 0xFD00000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL,
1017 0x0000000000000000ULL
1018 },
1019 {
1020 0xFDFDFD0000000000ULL,
1021 0xFDFD000000000000ULL,
1022 0xFD00000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL,
1027 0x0000000000000000ULL
1028 },
1029 {
1030 0xFDFDFDFD00000000ULL,
1031 0xFDFDFD0000000000ULL,
1032 0xFDFD000000000000ULL,
1033 0xFD00000000000000ULL,
1034 0x0000000000000000ULL,
1035 0x0000000000000000ULL,
1036 0x0000000000000000ULL,
1037 0x0000000000000000ULL
1038 },
1039 {
1040 0xFDFDFDFDFD000000ULL,
1041 0xFDFDFDFD00000000ULL,
1042 0xFDFDFD0000000000ULL,
1043 0xFDFD000000000000ULL,
1044 0xFD00000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL
1048 },
1049 {
1050 0xFDFDFDFDFDFD0000ULL,
1051 0xFDFDFDFDFD000000ULL,
1052 0xFDFDFDFD00000000ULL,
1053 0xFDFDFD0000000000ULL,
1054 0xFDFD000000000000ULL,
1055 0xFD00000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL
1058 },
1059 {
1060 0xFDFDFDFDFDFDFD00ULL,
1061 0xFDFDFDFDFDFD0000ULL,
1062 0xFDFDFDFDFD000000ULL,
1063 0xFDFDFDFD00000000ULL,
1064 0xFDFDFD0000000000ULL,
1065 0xFDFD000000000000ULL,
1066 0xFD00000000000000ULL,
1067 0x0000000000000000ULL
1068 },
1069 {
1070 0xFDFDFDFDFDFDFDFDULL,
1071 0xFDFDFDFDFDFDFD00ULL,
1072 0xFDFDFDFDFDFD0000ULL,
1073 0xFDFDFDFDFD000000ULL,
1074 0xFDFDFDFD00000000ULL,
1075 0xFDFDFD0000000000ULL,
1076 0xFDFD000000000000ULL,
1077 0xFD00000000000000ULL
1078 },
1079 {
1080 0xFDFDFDFDFDFDFDFDULL,
1081 0xFDFDFDFDFDFDFDFDULL,
1082 0xFDFDFDFDFDFDFD00ULL,
1083 0xFDFDFDFDFDFD0000ULL,
1084 0xFDFDFDFDFD000000ULL,
1085 0xFDFDFDFD00000000ULL,
1086 0xFDFDFD0000000000ULL,
1087 0xFDFD000000000000ULL
1088 },
1089 {
1090 0xFDFDFDFDFDFDFDFDULL,
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFDFDULL,
1093 0xFDFDFDFDFDFDFD00ULL,
1094 0xFDFDFDFDFDFD0000ULL,
1095 0xFDFDFDFDFD000000ULL,
1096 0xFDFDFDFD00000000ULL,
1097 0xFDFDFD0000000000ULL
1098 },
1099 {
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFDFDULL,
1104 0xFDFDFDFDFDFDFD00ULL,
1105 0xFDFDFDFDFDFD0000ULL,
1106 0xFDFDFDFDFD000000ULL,
1107 0xFDFDFDFD00000000ULL
1108 },
1109 {
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFDFDULL,
1115 0xFDFDFDFDFDFDFD00ULL,
1116 0xFDFDFDFDFDFD0000ULL,
1117 0xFDFDFDFDFD000000ULL
1118 },
1119 {
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFDFDULL,
1126 0xFDFDFDFDFDFDFD00ULL,
1127 0xFDFDFDFDFDFD0000ULL
1128 },
1129 {
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFDFDULL,
1137 0xFDFDFDFDFDFDFD00ULL
1138 },
1139 {
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFDFDULL
1148 }
1149 },
1150 {
1151 {
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL,
1159 0x0000000000000000ULL
1160 },
1161 {
1162 0x00000000000000FDULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL,
1169 0x0000000000000000ULL
1170 },
1171 {
1172 0x000000000000FDFDULL,
1173 0x00000000000000FDULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL,
1179 0x0000000000000000ULL
1180 },
1181 {
1182 0x0000000000FDFDFDULL,
1183 0x000000000000FDFDULL,
1184 0x00000000000000FDULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL,
1189 0x0000000000000000ULL
1190 },
1191 {
1192 0x00000000FDFDFDFDULL,
1193 0x0000000000FDFDFDULL,
1194 0x000000000000FDFDULL,
1195 0x00000000000000FDULL,
1196 0x0000000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL,
1199 0x0000000000000000ULL
1200 },
1201 {
1202 0x000000FDFDFDFDFDULL,
1203 0x00000000FDFDFDFDULL,
1204 0x0000000000FDFDFDULL,
1205 0x000000000000FDFDULL,
1206 0x00000000000000FDULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL
1210 },
1211 {
1212 0x0000FDFDFDFDFDFDULL,
1213 0x000000FDFDFDFDFDULL,
1214 0x00000000FDFDFDFDULL,
1215 0x0000000000FDFDFDULL,
1216 0x000000000000FDFDULL,
1217 0x00000000000000FDULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL
1220 },
1221 {
1222 0x00FDFDFDFDFDFDFDULL,
1223 0x0000FDFDFDFDFDFDULL,
1224 0x000000FDFDFDFDFDULL,
1225 0x00000000FDFDFDFDULL,
1226 0x0000000000FDFDFDULL,
1227 0x000000000000FDFDULL,
1228 0x00000000000000FDULL,
1229 0x0000000000000000ULL
1230 },
1231 {
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0x00FDFDFDFDFDFDFDULL,
1234 0x0000FDFDFDFDFDFDULL,
1235 0x000000FDFDFDFDFDULL,
1236 0x00000000FDFDFDFDULL,
1237 0x0000000000FDFDFDULL,
1238 0x000000000000FDFDULL,
1239 0x00000000000000FDULL
1240 },
1241 {
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0x00FDFDFDFDFDFDFDULL,
1245 0x0000FDFDFDFDFDFDULL,
1246 0x000000FDFDFDFDFDULL,
1247 0x00000000FDFDFDFDULL,
1248 0x0000000000FDFDFDULL,
1249 0x000000000000FDFDULL
1250 },
1251 {
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0x00FDFDFDFDFDFDFDULL,
1256 0x0000FDFDFDFDFDFDULL,
1257 0x000000FDFDFDFDFDULL,
1258 0x00000000FDFDFDFDULL,
1259 0x0000000000FDFDFDULL
1260 },
1261 {
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0xFDFDFDFDFDFDFDFDULL,
1266 0x00FDFDFDFDFDFDFDULL,
1267 0x0000FDFDFDFDFDFDULL,
1268 0x000000FDFDFDFDFDULL,
1269 0x00000000FDFDFDFDULL
1270 },
1271 {
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0xFDFDFDFDFDFDFDFDULL,
1277 0x00FDFDFDFDFDFDFDULL,
1278 0x0000FDFDFDFDFDFDULL,
1279 0x000000FDFDFDFDFDULL
1280 },
1281 {
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0xFDFDFDFDFDFDFDFDULL,
1288 0x00FDFDFDFDFDFDFDULL,
1289 0x0000FDFDFDFDFDFDULL
1290 },
1291 {
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0xFDFDFDFDFDFDFDFDULL,
1299 0x00FDFDFDFDFDFDFDULL
1300 },
1301 {
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0xFDFDFDFDFDFDFDFDULL
1310 }
1311 },
1312 {
1313 {
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL,
1321 0x0000000000000000ULL
1322 },
1323 {
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0x0000000000000000ULL,
1331 0xFD00000000000000ULL
1332 },
1333 {
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0x0000000000000000ULL,
1340 0xFD00000000000000ULL,
1341 0xFDFD000000000000ULL
1342 },
1343 {
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0x0000000000000000ULL,
1349 0xFD00000000000000ULL,
1350 0xFDFD000000000000ULL,
1351 0xFDFDFD0000000000ULL
1352 },
1353 {
1354 0x0000000000000000ULL,
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0x0000000000000000ULL,
1358 0xFD00000000000000ULL,
1359 0xFDFD000000000000ULL,
1360 0xFDFDFD0000000000ULL,
1361 0xFDFDFDFD00000000ULL
1362 },
1363 {
1364 0x0000000000000000ULL,
1365 0x0000000000000000ULL,
1366 0x0000000000000000ULL,
1367 0xFD00000000000000ULL,
1368 0xFDFD000000000000ULL,
1369 0xFDFDFD0000000000ULL,
1370 0xFDFDFDFD00000000ULL,
1371 0xFDFDFDFDFD000000ULL
1372 },
1373 {
1374 0x0000000000000000ULL,
1375 0x0000000000000000ULL,
1376 0xFD00000000000000ULL,
1377 0xFDFD000000000000ULL,
1378 0xFDFDFD0000000000ULL,
1379 0xFDFDFDFD00000000ULL,
1380 0xFDFDFDFDFD000000ULL,
1381 0xFDFDFDFDFDFD0000ULL
1382 },
1383 {
1384 0x0000000000000000ULL,
1385 0xFD00000000000000ULL,
1386 0xFDFD000000000000ULL,
1387 0xFDFDFD0000000000ULL,
1388 0xFDFDFDFD00000000ULL,
1389 0xFDFDFDFDFD000000ULL,
1390 0xFDFDFDFDFDFD0000ULL,
1391 0xFDFDFDFDFDFDFD00ULL
1392 },
1393 {
1394 0xFD00000000000000ULL,
1395 0xFDFD000000000000ULL,
1396 0xFDFDFD0000000000ULL,
1397 0xFDFDFDFD00000000ULL,
1398 0xFDFDFDFDFD000000ULL,
1399 0xFDFDFDFDFDFD0000ULL,
1400 0xFDFDFDFDFDFDFD00ULL,
1401 0xFDFDFDFDFDFDFDFDULL
1402 },
1403 {
1404 0xFDFD000000000000ULL,
1405 0xFDFDFD0000000000ULL,
1406 0xFDFDFDFD00000000ULL,
1407 0xFDFDFDFDFD000000ULL,
1408 0xFDFDFDFDFDFD0000ULL,
1409 0xFDFDFDFDFDFDFD00ULL,
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL
1412 },
1413 {
1414 0xFDFDFD0000000000ULL,
1415 0xFDFDFDFD00000000ULL,
1416 0xFDFDFDFDFD000000ULL,
1417 0xFDFDFDFDFDFD0000ULL,
1418 0xFDFDFDFDFDFDFD00ULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL,
1421 0xFDFDFDFDFDFDFDFDULL
1422 },
1423 {
1424 0xFDFDFDFD00000000ULL,
1425 0xFDFDFDFDFD000000ULL,
1426 0xFDFDFDFDFDFD0000ULL,
1427 0xFDFDFDFDFDFDFD00ULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL,
1431 0xFDFDFDFDFDFDFDFDULL
1432 },
1433 {
1434 0xFDFDFDFDFD000000ULL,
1435 0xFDFDFDFDFDFD0000ULL,
1436 0xFDFDFDFDFDFDFD00ULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL,
1441 0xFDFDFDFDFDFDFDFDULL
1442 },
1443 {
1444 0xFDFDFDFDFDFD0000ULL,
1445 0xFDFDFDFDFDFDFD00ULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL,
1451 0xFDFDFDFDFDFDFDFDULL
1452 },
1453 {
1454 0xFDFDFDFDFDFDFD00ULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL,
1461 0xFDFDFDFDFDFDFDFDULL
1462 },
1463 {
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL,
1469 0xFDFDFDFDFDFDFDFDULL,
1470 0xFDFDFDFDFDFDFDFDULL,
1471 0xFDFDFDFDFDFDFDFDULL
1472 }
1473 },
1474 {
1475 {
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL
1484 },
1485 {
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x0000000000000000ULL,
1493 0x00000000000000FDULL
1494 },
1495 {
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x0000000000000000ULL,
1502 0x00000000000000FDULL,
1503 0x000000000000FDFDULL
1504 },
1505 {
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x0000000000000000ULL,
1511 0x00000000000000FDULL,
1512 0x000000000000FDFDULL,
1513 0x0000000000FDFDFDULL
1514 },
1515 {
1516 0x0000000000000000ULL,
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x0000000000000000ULL,
1520 0x00000000000000FDULL,
1521 0x000000000000FDFDULL,
1522 0x0000000000FDFDFDULL,
1523 0x00000000FDFDFDFDULL
1524 },
1525 {
1526 0x0000000000000000ULL,
1527 0x0000000000000000ULL,
1528 0x0000000000000000ULL,
1529 0x00000000000000FDULL,
1530 0x000000000000FDFDULL,
1531 0x0000000000FDFDFDULL,
1532 0x00000000FDFDFDFDULL,
1533 0x000000FDFDFDFDFDULL
1534 },
1535 {
1536 0x0000000000000000ULL,
1537 0x0000000000000000ULL,
1538 0x00000000000000FDULL,
1539 0x000000000000FDFDULL,
1540 0x0000000000FDFDFDULL,
1541 0x00000000FDFDFDFDULL,
1542 0x000000FDFDFDFDFDULL,
1543 0x0000FDFDFDFDFDFDULL
1544 },
1545 {
1546 0x0000000000000000ULL,
1547 0x00000000000000FDULL,
1548 0x000000000000FDFDULL,
1549 0x0000000000FDFDFDULL,
1550 0x00000000FDFDFDFDULL,
1551 0x000000FDFDFDFDFDULL,
1552 0x0000FDFDFDFDFDFDULL,
1553 0x00FDFDFDFDFDFDFDULL
1554 },
1555 {
1556 0x00000000000000FDULL,
1557 0x000000000000FDFDULL,
1558 0x0000000000FDFDFDULL,
1559 0x00000000FDFDFDFDULL,
1560 0x000000FDFDFDFDFDULL,
1561 0x0000FDFDFDFDFDFDULL,
1562 0x00FDFDFDFDFDFDFDULL,
1563 0xFDFDFDFDFDFDFDFDULL
1564 },
1565 {
1566 0x000000000000FDFDULL,
1567 0x0000000000FDFDFDULL,
1568 0x00000000FDFDFDFDULL,
1569 0x000000FDFDFDFDFDULL,
1570 0x0000FDFDFDFDFDFDULL,
1571 0x00FDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL
1574 },
1575 {
1576 0x0000000000FDFDFDULL,
1577 0x00000000FDFDFDFDULL,
1578 0x000000FDFDFDFDFDULL,
1579 0x0000FDFDFDFDFDFDULL,
1580 0x00FDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL,
1583 0xFDFDFDFDFDFDFDFDULL
1584 },
1585 {
1586 0x00000000FDFDFDFDULL,
1587 0x000000FDFDFDFDFDULL,
1588 0x0000FDFDFDFDFDFDULL,
1589 0x00FDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL,
1593 0xFDFDFDFDFDFDFDFDULL
1594 },
1595 {
1596 0x000000FDFDFDFDFDULL,
1597 0x0000FDFDFDFDFDFDULL,
1598 0x00FDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL,
1603 0xFDFDFDFDFDFDFDFDULL
1604 },
1605 {
1606 0x0000FDFDFDFDFDFDULL,
1607 0x00FDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL,
1613 0xFDFDFDFDFDFDFDFDULL
1614 },
1615 {
1616 0x00FDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL,
1623 0xFDFDFDFDFDFDFDFDULL
1624 },
1625 {
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL,
1631 0xFDFDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL,
1633 0xFDFDFDFDFDFDFDFDULL
1634 }
1635 }
1636 };
1637
1638 int32_t black_opening_count=0;
1639 int32_t black_opening_x,black_opening_y;
1640 int32_t black_opening_shape;
1641
1642 443 int32_t choose_opening_shape()
1643 {
1644 // First, count how many bits are set
1645 443 int32_t numBits=0;
1646 int32_t bitCounter;
1647
1648
2/2
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 443 times.
2658 for(int32_t i=0; i<bosMAX; i++)
1649 {
1650
2/2
✓ Branch 0 taken 1556 times.
✓ Branch 1 taken 659 times.
2215 if(COOLSCROLL&(1<<i))
1651 659 numBits++;
1652 2215 }
1653
1654 // Shouldn't happen...
1655
1/2
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
443 if(numBits==0)
1656 return bosCIRCLE;
1657
1658 // Pick a bit
1659 443 bitCounter=zc_rand()%numBits+1;
1660
1661
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 26 times.
681 for(int32_t i=0; i<bosMAX; i++)
1662 {
1663 // If this bit is set, decrement the bit counter
1664
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 573 times.
655 if(COOLSCROLL&(1<<i))
1665 573 bitCounter--;
1666
1667 // When the counter hits 0, return a value based on
1668 // which bit it stopped on.
1669 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1670
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 238 times.
655 if(bitCounter==0)
1671 417 return i;
1672 238 }
1673
1674 // Shouldn't be necessary, but the compiler might complain, at least
1675 26 return bosCIRCLE;
1676 443 }
1677
1678 140 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1679 {
1680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1681
1682 140 int32_t w=256, h=224;
1683 140 int32_t blockrows=28, blockcolumns=32;
1684 140 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1685
1686
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 140 times.
4060 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1687 {
1688
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 3920 times.
129360 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1689 {
1690
2/2
✓ Branch 0 taken 67190 times.
✓ Branch 1 taken 58250 times.
125440 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1691 125440 }
1692 3920 }
1693
1694 140 black_opening_count = 66;
1695 140 black_opening_x = x;
1696 140 black_opening_y = y;
1697 140 lensclk = 0;
1698 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1699
1700
1701
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(black_opening_shape == bosFADEBLACK)
1702 {
1703 refreshTints();
1704 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1705 }
1706
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(wait)
1707 {
1708 FFCore.warpScriptCheck();
1709 for(int32_t i=0; i<66; i++)
1710 {
1711 draw_screen(tmpscr);
1712 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1713 syskeys();
1714 advanceframe(true);
1715
1716 if(Quit)
1717 {
1718 break;
1719 }
1720 }
1721 }
1722 140 }
1723
1724 303 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1725 {
1726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
303 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1727
1728 303 int32_t w=256, h=224;
1729 303 int32_t blockrows=28, blockcolumns=32;
1730 303 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1731
1732
2/2
✓ Branch 0 taken 8484 times.
✓ Branch 1 taken 303 times.
8787 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1733 {
1734
2/2
✓ Branch 0 taken 271488 times.
✓ Branch 1 taken 8484 times.
279972 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1735 {
1736
2/2
✓ Branch 0 taken 130365 times.
✓ Branch 1 taken 141123 times.
271488 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1737 271488 }
1738 8484 }
1739
1740 303 black_opening_count = -66;
1741 303 black_opening_x = x;
1742 303 black_opening_y = y;
1743 303 lensclk = 0;
1744
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if(black_opening_shape == bosFADEBLACK)
1745 {
1746 refreshTints();
1747 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1748 }
1749
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 193 times.
303 if(wait)
1750 {
1751 193 FFCore.warpScriptCheck();
1752
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 12738 times.
12931 for(int32_t i=0; i<66; i++)
1753 {
1754 12738 draw_screen(tmpscr);
1755 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1756 12738 syskeys();
1757 12738 advanceframe(true);
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12738 times.
12738 if(Quit)
1760 {
1761 break;
1762 }
1763 12738 }
1764 193 }
1765 303 }
1766
1767 29238 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1768 {
1769 29238 clear_to_color(tmp_scr,BLACK);
1770 29238 int32_t w=256, h=224;
1771
1772
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26070 times.
29238 switch(black_opening_shape)
1773 {
1774 case bosOVAL:
1775 {
1776 858 double new_w=(w/2)+abs(w/2-x);
1777 858 double new_h=(h/2)+abs(h/2-y);
1778 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1779 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1780 858 break;
1781 }
1782
1783 case bosTRIANGLE:
1784 {
1785 660 double new_w=(w/2)+abs(w/2-x);
1786 660 double new_h=(h/2)+abs(h/2-y);
1787 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1788 660 double P2= (PI/2);
1789 660 double P23=(2*PI/3);
1790 660 double P43=(4*PI/3);
1791 660 double Pa= (-4*PI*a/(3*max_a));
1792 660 double angle=P2+Pa;
1793 660 double a0=angle;
1794 660 double a2=angle+P23;
1795 660 double a4=angle+P43;
1796 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1797 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1798 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1799 0);
1800 660 break;
1801 }
1802
1803 case bosSMAS:
1804 {
1805
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1806
1807
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1808 {
1809
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1810 {
1811 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1812
1813
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1814 {
1815 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1816
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1817 11827200 [linerow];
1818 11827200 ++triangleline;
1819
1820
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1821 {
1822 1478400 }
1823 11827200 }
1824 369600 }
1825 46200 }
1826
1827 1650 break;
1828 }
1829
1830 case bosFADEBLACK:
1831 {
1832 if(black_opening_count<0)
1833 {
1834 black_fade(zc_min(-black_opening_count,63));
1835 }
1836 else if(black_opening_count>0)
1837 {
1838 black_fade(63-zc_max(black_opening_count-3,0));
1839 }
1840 else black_fade(0);
1841 return; //no blitting from tmp_scr!
1842 }
1843
1844 26070 case bosCIRCLE:
1845 default:
1846 {
1847 26070 double new_w=(w/2)+abs(w/2-x);
1848 26070 double new_h=(h/2)+abs(h/2-y);
1849 26070 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1850 //circlefill(tmp_scr,x,y,a<<3,0);
1851 26070 circlefill(tmp_scr,x,y,r,0);
1852 26070 break;
1853 }
1854 }
1855
1856 29238 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1857 29238 }
1858
1859
1860 void black_fade(int32_t fadeamnt)
1861 {
1862 for(int32_t i=0; i < 0xEF; i++)
1863 {
1864 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1865 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1866 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1867 }
1868
1869 refreshpal = true;
1870 }
1871
1872 //----------------------------------------------------------------
1873
1874 12295377 bool item_disabled(int32_t item) //is this item disabled?
1875 {
1876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12295377 times.
12295377 return (item>=0 && game->items_off[item] != 0);
1877 }
1878
1879 3250036 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1880 {
1881
2/2
✓ Branch 0 taken 20760 times.
✓ Branch 1 taken 3229276 times.
3250036 if(current_item(item_type, true) >=item)
1882 {
1883 20760 return true;
1884 }
1885
1886 3229276 return false;
1887 3250036 }
1888
1889 15983874 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1890 {
1891
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 2397978 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1831366 times.
✓ Branch 6 taken 8858450 times.
✓ Branch 7 taken 2878292 times.
✓ Branch 8 taken 17788 times.
15983874 switch(item_type)
1892 {
1893 case itype_bomb:
1894 case itype_sbomb:
1895 {
1896 int32_t itemid = getItemID(itemsbuf, item_type, it);
1897
1898 if(itemid == -1)
1899 return false;
1900
1901 return (game->get_item(itemid));
1902 }
1903
1904 case itype_clock:
1905 {
1906 2397978 int32_t itemid = getItemID(itemsbuf, item_type, it);
1907
1908
2/4
✓ Branch 0 taken 2397978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2397978 times.
✗ Branch 3 not taken.
2397978 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1909 return (game->get_item(itemid));
1910 2397978 return Hero.getClock()?1:0;
1911 }
1912
1913 case itype_key:
1914 return (game->get_keys()>0);
1915
1916 case itype_magiccontainer:
1917 return (game->get_maxmagic()>=game->get_mp_per_block());
1918
1919 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1920 {
1921
1/3
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1831366 switch(it)
1922 {
1923 case -2:
1924 {
1925 for(int32_t i=0; i<MAXLEVELS; i++)
1926 {
1927 if(game->lvlitems[i]&liTRIFORCE)
1928 {
1929 return true;
1930 }
1931 }
1932
1933 return false;
1934 }
1935
1936 case -1:
1937 return (game->lvlitems[dlevel]&liTRIFORCE);
1938
1939 default:
1940
2/4
✓ Branch 0 taken 1831366 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1831366 times.
1831366 if(it>=0&&it<MAXLEVELS)
1941 {
1942 1831366 return (game->lvlitems[it]&liTRIFORCE);
1943 }
1944
1945 break;
1946 }
1947
1948 return 0;
1949 }
1950
1951 case itype_map: //it: -2=any, -1=current level, other=that level
1952 {
1953
1/3
✓ Branch 0 taken 8858450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
8858450 switch(it)
1954 {
1955 case -2:
1956 {
1957 for(int32_t i=0; i<MAXLEVELS; i++)
1958 {
1959 if(game->lvlitems[i]&liMAP)
1960 {
1961 return true;
1962 }
1963 }
1964
1965 return false;
1966 }
1967
1968 case -1:
1969 return (game->lvlitems[dlevel]&liMAP)!=0;
1970
1971 default:
1972
2/4
✓ Branch 0 taken 8858450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8858450 times.
8858450 if(it>=0&&it<MAXLEVELS)
1973 {
1974 8858450 return (game->lvlitems[it]&liMAP)!=0;
1975 }
1976
1977 break;
1978 }
1979
1980 return 0;
1981 }
1982
1983 case itype_compass: //it: -2=any, -1=current level, other=that level
1984 {
1985
1/3
✓ Branch 0 taken 2878292 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2878292 switch(it)
1986 {
1987 case -2:
1988 {
1989 for(int32_t i=0; i<MAXLEVELS; i++)
1990 {
1991 if(game->lvlitems[i]&liCOMPASS)
1992 {
1993 return true;
1994 }
1995 }
1996
1997 return false;
1998 }
1999
2000 case -1:
2001 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2002
2003 default:
2004
2/4
✓ Branch 0 taken 2878292 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2878292 times.
✗ Branch 3 not taken.
2878292 if(it>=0&&it<MAXLEVELS)
2005 {
2006 2878292 return (game->lvlitems[it]&liCOMPASS)!=0;
2007 }
2008
2009 break;
2010 }
2011 return 0;
2012 }
2013
2014 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2015 {
2016
1/3
✓ Branch 0 taken 17788 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
17788 switch(it)
2017 {
2018 case -2:
2019 {
2020 for(int32_t i=0; i<MAXLEVELS; i++)
2021 {
2022 if(game->lvlitems[i]&liBOSSKEY)
2023 {
2024 return true;
2025 }
2026 }
2027
2028 return false;
2029 }
2030
2031 case -1:
2032 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2033
2034 default:
2035
2/4
✓ Branch 0 taken 17788 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17788 times.
17788 if(it>=0&&it<MAXLEVELS)
2036 {
2037 17788 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2038 }
2039 break;
2040 }
2041 return 0;
2042 }
2043
2044 default:
2045 //it=(1<<(it-1));
2046 /*if (item_type>=itype_max)
2047 {
2048 system_pal();
2049 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2050 game_pal();
2051
2052 return false;
2053 }*/
2054 int32_t itemid = getItemID(itemsbuf, item_type, it);
2055
2056 if(itemid == -1)
2057 return false;
2058
2059 return game->get_item(itemid);
2060 }
2061 15983874 }
2062
2063
2064 41839323 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2065 {
2066
9/9
✓ Branch 0 taken 2397978 times.
✓ Branch 1 taken 22655499 times.
✓ Branch 2 taken 2397978 times.
✓ Branch 3 taken 2397978 times.
✓ Branch 4 taken 2397978 times.
✓ Branch 5 taken 2397978 times.
✓ Branch 6 taken 2397978 times.
✓ Branch 7 taken 2397978 times.
✓ Branch 8 taken 2397978 times.
41839323 switch(item_type)
2067 {
2068 case itype_clock:
2069 {
2070 2397978 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2071
2072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2397978 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2397978 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2073 return itemsbuf[maxid].fam_type;
2074
2075 2397978 return has_item(itype_clock,1) ? 1 : 0;
2076 }
2077
2078 case itype_key:
2079 2397978 return game->get_keys();
2080
2081 case itype_lkey:
2082 2397978 return game->lvlkeys[get_dlevel()];
2083
2084 case itype_magiccontainer:
2085 2397978 return game->get_maxmagic()/game->get_mp_per_block();
2086
2087 case itype_triforcepiece:
2088 {
2089 2397978 int32_t count=0;
2090
2091
2/2
✓ Branch 0 taken 1227764736 times.
✓ Branch 1 taken 2397978 times.
1230162714 for(int32_t i=0; i<MAXLEVELS; i++)
2092 {
2093 1227764736 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2094 1227764736 }
2095
2096 2397978 return count;
2097 }
2098
2099 case itype_map:
2100 {
2101 2397978 int32_t count=0;
2102
2103
2/2
✓ Branch 0 taken 1227764736 times.
✓ Branch 1 taken 2397978 times.
1230162714 for(int32_t i=0; i<MAXLEVELS; i++)
2104 {
2105 1227764736 count+=(game->lvlitems[i]&liMAP)?1:0;
2106 1227764736 }
2107
2108 2397978 return count;
2109 }
2110
2111 case itype_compass:
2112 {
2113 2397978 int32_t count=0;
2114
2115
2/2
✓ Branch 0 taken 1227764736 times.
✓ Branch 1 taken 2397978 times.
1230162714 for(int32_t i=0; i<MAXLEVELS; i++)
2116 {
2117 1227764736 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2118 1227764736 }
2119
2120 2397978 return count;
2121 }
2122
2123 case itype_bosskey:
2124 {
2125 2397978 int32_t count=0;
2126
2127
2/2
✓ Branch 0 taken 1227764736 times.
✓ Branch 1 taken 2397978 times.
1230162714 for(int32_t i=0; i<MAXLEVELS; i++)
2128 {
2129 1227764736 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2130 1227764736 }
2131
2132 2397978 return count;
2133 }
2134
2135 default:
2136 22655499 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2137
2138
2/2
✓ Branch 0 taken 5294971 times.
✓ Branch 1 taken 17360528 times.
22655499 if(maxid == -1)
2139 17360528 return 0;
2140
2141 5294971 return itemsbuf[maxid].fam_type;
2142 }
2143 41839323 }
2144
2145 38589287 int32_t current_item(int32_t item_type) //item currently being used
2146 {
2147 38589287 return current_item(item_type, true);
2148 }
2149
2150 15 std::map<int32_t, int32_t> itemcache;
2151
2152 // Not actually used by anything at the moment...
2153 void removeFromItemCache(int32_t itemid)
2154 {
2155 itemcache.erase(itemid);
2156 }
2157
2158 11629 void flushItemCache()
2159 {
2160 11629 itemcache.clear();
2161
2162 //also fix the active subscreen if items were deleted -DD
2163
1/2
✓ Branch 0 taken 11629 times.
✗ Branch 1 not taken.
11629 if(game != NULL)
2164 {
2165 11629 verifyBothWeapons();
2166 11629 load_Sitems(&QMisc);
2167 11629 }
2168 11629 }
2169
2170 // This is used often, so it should be as direct as possible.
2171 1350653074 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2172 {
2173
2/2
✓ Branch 0 taken 1316168922 times.
✓ Branch 1 taken 34484152 times.
1350653074 if(jinx_check)
2174 {
2175
4/4
✓ Branch 0 taken 20579785 times.
✓ Branch 1 taken 13904367 times.
✓ Branch 2 taken 17172759 times.
✓ Branch 3 taken 3407026 times.
34484152 if(!(HeroSwordClk() || HeroItemClk()))
2176 17172759 jinx_check = false; //not jinxed
2177 34484152 }
2178
4/4
✓ Branch 0 taken 1340101856 times.
✓ Branch 1 taken 10551218 times.
✓ Branch 2 taken 17187779 times.
✓ Branch 3 taken 1322914077 times.
1350653074 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2179 {
2180 1322914077 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2181
2182
2/2
✓ Branch 0 taken 1316977475 times.
✓ Branch 1 taken 5936602 times.
1322914077 if(res != itemcache.end())
2183 1316977475 return res->second;
2184 5936602 }
2185
2186 33675599 int32_t result = -1;
2187 33675599 int32_t highestlevel = -1;
2188
2189
2/2
✓ Branch 0 taken 8620953344 times.
✓ Branch 1 taken 33675599 times.
8654628943 for(int32_t i=0; i<MAXITEMS; i++)
2190 {
2191
5/6
✓ Branch 0 taken 732524832 times.
✓ Branch 1 taken 7888428512 times.
✓ Branch 2 taken 11961034 times.
✓ Branch 3 taken 720563798 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11961034 times.
8620953344 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2192 {
2193
4/4
✓ Branch 0 taken 3035361 times.
✓ Branch 1 taken 8925673 times.
✓ Branch 2 taken 912131 times.
✓ Branch 3 taken 11048903 times.
11961034 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2194 {
2195 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2196
2/2
✓ Branch 0 taken 11048835 times.
✓ Branch 1 taken 68 times.
11048903 if(!checkmagiccost(i))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2199 }
2200 11048835 }
2201
6/6
✓ Branch 0 taken 10134370 times.
✓ Branch 1 taken 1826596 times.
✓ Branch 2 taken 179744 times.
✓ Branch 3 taken 1646852 times.
✓ Branch 4 taken 1162657 times.
✓ Branch 5 taken 663939 times.
11960966 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2202 {
2203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663939 times.
663939 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2204 663939 continue;
2205 }
2206
2207
2/2
✓ Branch 0 taken 177180 times.
✓ Branch 1 taken 11119847 times.
11297027 if(itemsbuf[i].fam_type >= highestlevel)
2208 {
2209 11119847 highestlevel = itemsbuf[i].fam_type;
2210 11119847 result=i;
2211 11119847 }
2212 11297027 }
2213 8620289337 }
2214
2215
2/2
✓ Branch 0 taken 17311393 times.
✓ Branch 1 taken 16364206 times.
33675599 if(!jinx_check) //Can't cache jinx_check results
2216 16364206 itemcache[itemtype] = result;
2217 33675599 return result;
2218 1350653074 }
2219
2220 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2221 1333577323 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2222 {
2223 1333577323 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2224
2/2
✓ Branch 0 taken 17408401 times.
✓ Branch 1 taken 1316168922 times.
1333577323 if(!jinx_check) //If not already a jinx-immune-only check...
2225 {
2226 //And the player IS jinxed...
2227
4/4
✓ Branch 0 taken 1302450535 times.
✓ Branch 1 taken 13718387 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1299093171 times.
1316168922 if(HeroSwordClk() || HeroItemClk())
2228 {
2229 //Then do a jinx-immune-only check here
2230 17075751 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2231 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2232 //Should NOT need a compat rule, as this should always return -1 in old quests.
2233
2/2
✓ Branch 0 taken 797035 times.
✓ Branch 1 taken 16278716 times.
17075751 if(ret2 > -1) return ret2;
2234 16278716 }
2235 1315371887 }
2236 1332780288 return ret;
2237 1333577323 }
2238 10535138 int32_t current_item_power(int32_t itemtype)
2239 {
2240 10535138 int32_t result = current_item_id(itemtype,true);
2241
2/2
✓ Branch 0 taken 7305709 times.
✓ Branch 1 taken 3229429 times.
10535138 return (result<0) ? 0 : itemsbuf[result].power;
2242 }
2243
2244 4 int32_t heart_container_id()
2245 {
2246
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 for(int32_t i=0; i<MAXITEMS; i++)
2247 {
2248
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 if(itemsbuf[i].family == itype_heartcontainer)
2249 {
2250 4 return i;
2251 }
2252 112 }
2253 return -1;
2254 4 }
2255
2256 2397978 int32_t item_tile_mod()
2257 {
2258 2397978 int32_t tile=0;
2259
2260
2/2
✓ Branch 0 taken 402188 times.
✓ Branch 1 taken 1995790 times.
2397978 if(game->get_bombs())
2261 {
2262 1995790 int32_t itemid = current_item_id(itype_bomb,false);
2263
3/4
✓ Branch 0 taken 1914731 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1914731 times.
1995790 if(itemid > -1 && checkbunny(itemid))
2264 1914731 tile+=itemsbuf[itemid].ltm;
2265 1995790 }
2266
2267
2/2
✓ Branch 0 taken 1959189 times.
✓ Branch 1 taken 438789 times.
2397978 if(game->get_sbombs())
2268 {
2269 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2270
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2271 437361 tile+=itemsbuf[itemid].ltm;
2272 438789 }
2273
2274
2/2
✓ Branch 0 taken 2320709 times.
✓ Branch 1 taken 77269 times.
2397978 if(current_item(itype_clock))
2275 {
2276 77269 int32_t itemid =
2277
1/2
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
77269 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2278 ? iClock
2279 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2280
2/4
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77269 times.
77269 if(itemid > -1 && checkbunny(itemid))
2281 77269 tile+=itemsbuf[itemid].ltm;
2282 77269 }
2283
2284
2/2
✓ Branch 0 taken 1805710 times.
✓ Branch 1 taken 592268 times.
2397978 if(current_item(itype_key))
2285 {
2286 592268 int32_t itemid =
2287
1/2
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
592268 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2288 ? iKey
2289 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2290
2/4
✓ Branch 0 taken 592268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 592268 times.
592268 if(itemid > -1 && checkbunny(itemid))
2291 592268 tile+=itemsbuf[itemid].ltm;
2292 592268 }
2293
2294
2/2
✓ Branch 0 taken 2278271 times.
✓ Branch 1 taken 119707 times.
2397978 if(current_item(itype_lkey))
2295 {
2296 119707 int32_t itemid =
2297
2/2
✓ Branch 0 taken 118797 times.
✓ Branch 1 taken 910 times.
119707 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2298 ? iLevelKey
2299 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2300
2/4
✓ Branch 0 taken 119707 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119707 times.
119707 if(itemid > -1 && checkbunny(itemid))
2301 119707 tile+=itemsbuf[itemid].ltm;
2302 119707 }
2303
2304
2/2
✓ Branch 0 taken 235871 times.
✓ Branch 1 taken 2162107 times.
2397978 if(current_item(itype_map))
2305 {
2306 2162107 int32_t itemid =
2307
2/2
✓ Branch 0 taken 2161321 times.
✓ Branch 1 taken 786 times.
2162107 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2308 ? iMap
2309 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2310
2/4
✓ Branch 0 taken 2162107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2162107 times.
2162107 if(itemid > -1 && checkbunny(itemid))
2311 2162107 tile+=itemsbuf[itemid].ltm;
2312 2162107 }
2313
2314
2/2
✓ Branch 0 taken 109321 times.
✓ Branch 1 taken 2288657 times.
2397978 if(current_item(itype_compass))
2315 {
2316 2288657 int32_t itemid =
2317
2/2
✓ Branch 0 taken 2207598 times.
✓ Branch 1 taken 81059 times.
2288657 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2318 ? iCompass
2319 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2320
2/4
✓ Branch 0 taken 2288657 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2288657 times.
2288657 if(itemid > -1 && checkbunny(itemid))
2321 2288657 tile+=itemsbuf[itemid].ltm;
2322 2288657 }
2323
2324
2/2
✓ Branch 0 taken 602116 times.
✓ Branch 1 taken 1795862 times.
2397978 if(current_item(itype_bosskey))
2325 {
2326 1795862 int32_t itemid =
2327
1/2
✓ Branch 0 taken 1795862 times.
✗ Branch 1 not taken.
1795862 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2328 ? iBossKey
2329 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2330
2/4
✓ Branch 0 taken 1795862 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1795862 times.
1795862 if(itemid > -1 && checkbunny(itemid))
2331 1795862 tile+=itemsbuf[itemid].ltm;
2332 1795862 }
2333
2334
2/2
✓ Branch 0 taken 2038151 times.
✓ Branch 1 taken 359827 times.
2397978 if(current_item(itype_magiccontainer))
2335 {
2336 359827 int32_t itemid =
2337
2/2
✓ Branch 0 taken 277982 times.
✓ Branch 1 taken 81845 times.
359827 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2338 ? iMagicC
2339 81845 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2340
2/4
✓ Branch 0 taken 359827 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 359827 times.
359827 if(itemid > -1 && checkbunny(itemid))
2341 359827 tile+=itemsbuf[itemid].ltm;
2342 359827 }
2343
2344
2/2
✓ Branch 0 taken 421391 times.
✓ Branch 1 taken 1976587 times.
2397978 if(current_item(itype_triforcepiece))
2345 {
2346 1976587 int32_t itemid =
2347
1/2
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
1976587 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2348 ? iTriforce
2349 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2350
2/4
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1976587 times.
1976587 if(itemid > -1 && checkbunny(itemid))
2351 1976587 tile+=itemsbuf[itemid].ltm;
2352 1976587 }
2353
2354
2/2
✓ Branch 0 taken 2397978 times.
✓ Branch 1 taken 1227764736 times.
1230162714 for(int32_t i=0; i<itype_max; i++)
2355 {
2356
2/2
✓ Branch 0 taken 1178479616 times.
✓ Branch 1 taken 49285120 times.
1227764736 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2357 {
2358
2/2
✓ Branch 0 taken 962600 times.
✓ Branch 1 taken 48322520 times.
49285120 switch(i)
2359 {
2360 case itype_bomb:
2361 case itype_sbomb:
2362 case itype_clock:
2363 case itype_key:
2364 case itype_lkey:
2365 case itype_map:
2366 case itype_compass:
2367 case itype_bosskey:
2368 case itype_magiccontainer:
2369 case itype_triforcepiece:
2370 962600 continue; //already handled
2371 }
2372 48322520 }
2373 1226802136 int32_t itemid = current_item_id(i,false);
2374
2/2
✓ Branch 0 taken 1224404158 times.
✓ Branch 1 taken 2397978 times.
1226802136 if(i == itype_shield)
2375 2397978 itemid = getCurrentShield(false);
2376
2377
3/4
✓ Branch 0 taken 36538782 times.
✓ Branch 1 taken 1190263354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36538782 times.
1226802136 if(itemid < 0 || !checkbunny(itemid))
2378 1190263354 continue;
2379
2380 36538782 itemdata const& itm = itemsbuf[itemid];
2381
2382
2/2
✓ Branch 0 taken 34221863 times.
✓ Branch 1 taken 2316919 times.
36538782 switch(itm.family)
2383 {
2384 case itype_shield:
2385
1/2
✓ Branch 0 taken 2316919 times.
✗ Branch 1 not taken.
2316919 if(itm.flags & ITEM_FLAG9) //active shield
2386 {
2387 if(!usingActiveShield(itemid))
2388 {
2389 tile+=itm.misc6; //'Inactive PTM'
2390 continue;
2391 }
2392 }
2393 2316919 break;
2394 }
2395
2396 36538782 tile+=itm.ltm;
2397 36538782 }
2398
2399 2397978 return tile;
2400 }
2401
2402 2397978 int32_t bunny_tile_mod()
2403 {
2404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2397978 times.
2397978 if(Hero.BunnyClock())
2405 {
2406 return game->get_bunny_ltm();
2407 }
2408 2397978 return 0;
2409 2397978 }
2410
2411 // Hints are drawn on a separate layer to combo reveals.
2412 8618 void draw_lens_under(BITMAP *dest, bool layer)
2413 {
2414 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2415 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2416 //Lens flag 3: Don't show armos/chest/dive items
2417 //Lens flag 4: Show Raft Paths
2418 //Lens flag 5: Show Invisible Enemies
2419
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8618 times.
✓ Branch 2 taken 4309 times.
✓ Branch 3 taken 4309 times.
8618 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2420
2421 8618 int32_t strike_hint_table[11]=
2422 {
2423 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2424 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2425 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2426 };
2427
2428 // int32_t page = tmpscr->cpage;
2429 {
2430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8618 times.
8618 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2431 // int32_t temptimer=0;
2432 8618 int32_t tempitem, tempweapon=0;
2433 8618 strike_hint=strike_hint_table[strike_hint_counter];
2434
2435
2/2
✓ Branch 0 taken 8358 times.
✓ Branch 1 taken 260 times.
8618 if(strike_hint_timer>32)
2436 {
2437 260 strike_hint_timer=0;
2438 260 strike_hint_counter=((strike_hint_counter+1)%11);
2439 260 }
2440
2441 8618 ++strike_hint_timer;
2442
2443
2/2
✓ Branch 0 taken 1516768 times.
✓ Branch 1 taken 8618 times.
1525386 for(int32_t i=0; i<176; i++)
2444 {
2445 1516768 int32_t x = (i & 15) << 4;
2446 1516768 int32_t y = (i & 0xF0) + playing_field_offset;
2447 1516768 int32_t tempitemx=-16, tempitemy=-16;
2448 1516768 int32_t tempweaponx=-16, tempweapony=-16;
2449
2450
2/2
✓ Branch 0 taken 3033536 times.
✓ Branch 1 taken 1516768 times.
4550304 for(int32_t iter=0; iter<2; ++iter)
2451 {
2452 3033536 int32_t checkflag=0;
2453
2454
2/2
✓ Branch 0 taken 1516768 times.
✓ Branch 1 taken 1516768 times.
3033536 if(iter==0)
2455 {
2456 1516768 checkflag=combobuf[tmpscr->data[i]].flag;
2457 1516768 }
2458 else
2459 {
2460 1516768 checkflag=tmpscr->sflag[i];
2461 }
2462
2463
2/2
✓ Branch 0 taken 3033152 times.
✓ Branch 1 taken 384 times.
3033536 if(checkflag==mfSTRIKE)
2464 {
2465
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 192 times.
384 if(!hints)
2466 {
2467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2468 192 }
2469 else
2470 {
2471 192 checkflag = strike_hint;
2472 }
2473 384 }
2474
2475
19/36
✓ Branch 0 taken 2997346 times.
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 2016 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28392 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 118 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192 times.
3033536 switch(checkflag)
2476 {
2477 case 0:
2478 case mfZELDA:
2479 case mfPUSHED:
2480 case mfENEMY0:
2481 case mfENEMY1:
2482 case mfENEMY2:
2483 case mfENEMY3:
2484 case mfENEMY4:
2485 case mfENEMY5:
2486 case mfENEMY6:
2487 case mfENEMY7:
2488 case mfENEMY8:
2489 case mfENEMY9:
2490 case mfSINGLE:
2491 case mfSINGLE16:
2492 case mfNOENEMY:
2493 case mfTRAP_H:
2494 case mfTRAP_V:
2495 case mfTRAP_4:
2496 case mfTRAP_LR:
2497 case mfTRAP_UD:
2498 case mfNOGROUNDENEMY:
2499 case mfNOBLOCKS:
2500 case mfSCRIPT1:
2501 case mfSCRIPT2:
2502 case mfSCRIPT3:
2503 case mfSCRIPT4:
2504 case mfSCRIPT5:
2505 case mfSCRIPT6:
2506 case mfSCRIPT7:
2507 case mfSCRIPT8:
2508 case mfSCRIPT9:
2509 case mfSCRIPT10:
2510 case mfSCRIPT11:
2511 case mfSCRIPT12:
2512 case mfSCRIPT13:
2513 case mfSCRIPT14:
2514 case mfSCRIPT15:
2515 case mfSCRIPT16:
2516 case mfSCRIPT17:
2517 case mfSCRIPT18:
2518 case mfSCRIPT19:
2519 case mfSCRIPT20:
2520 case mfPITHOLE:
2521 case mfPITFALLFLOOR:
2522 case mfLAVA:
2523 case mfICE:
2524 case mfICEDAMAGE:
2525 case mfDAMAGE1:
2526 case mfDAMAGE2:
2527 case mfDAMAGE4:
2528 case mfDAMAGE8:
2529 case mfDAMAGE16:
2530 case mfDAMAGE32:
2531 case mfFREEZEALL:
2532 case mfFREZEALLANSFFCS:
2533 case mfFREEZEFFCSOLY:
2534 case mfSCRITPTW1TRIG:
2535 case mfSCRITPTW2TRIG:
2536 case mfSCRITPTW3TRIG:
2537 case mfSCRITPTW4TRIG:
2538 case mfSCRITPTW5TRIG:
2539 case mfSCRITPTW6TRIG:
2540 case mfSCRITPTW7TRIG:
2541 case mfSCRITPTW8TRIG:
2542 case mfSCRITPTW9TRIG:
2543 case mfSCRITPTW10TRIG:
2544 case mfTROWEL:
2545 case mfTROWELNEXT:
2546 case mfTROWELSPECIALITEM:
2547 case mfSLASHPOT:
2548 case mfLIFTPOT:
2549 case mfLIFTORSLASH:
2550 case mfLIFTROCK:
2551 case mfLIFTROCKHEAVY:
2552 case mfDROPITEM:
2553 case mfSPECIALITEM:
2554 case mfDROPKEY:
2555 case mfDROPLKEY:
2556 case mfDROPCOMPASS:
2557 case mfDROPMAP:
2558 case mfDROPBOSSKEY:
2559 case mfSPAWNNPC:
2560 case mfSWITCHHOOK:
2561 case mfSIDEVIEWLADDER:
2562 case mfSIDEVIEWPLATFORM:
2563 case mfNOENEMYSPAWN:
2564 case mfENEMYALL:
2565 case mfNOMIRROR:
2566 case mfUNSAFEGROUND:
2567 case mf168:
2568 case mf169:
2569 case mf170:
2570 case mf171:
2571 case mf172:
2572 case mf173:
2573 case mf174:
2574 case mf175:
2575 case mf176:
2576 case mf177:
2577 case mf178:
2578 case mf179:
2579 case mf180:
2580 case mf181:
2581 case mf182:
2582 case mf183:
2583 case mf184:
2584 case mf185:
2585 case mf186:
2586 case mf187:
2587 case mf188:
2588 case mf189:
2589 case mf190:
2590 case mf191:
2591 case mf192:
2592 case mf193:
2593 case mf194:
2594 case mf195:
2595 case mf196:
2596 case mf197:
2597 case mf198:
2598 case mf199:
2599 case mf200:
2600 case mf201:
2601 case mf202:
2602 case mf203:
2603 case mf204:
2604 case mf205:
2605 case mf206:
2606 case mf207:
2607 case mf208:
2608 case mf209:
2609 case mf210:
2610 case mf211:
2611 case mf212:
2612 case mf213:
2613 case mf214:
2614 case mf215:
2615 case mf216:
2616 case mf217:
2617 case mf218:
2618 case mf219:
2619 case mf220:
2620 case mf221:
2621 case mf222:
2622 case mf223:
2623 case mf224:
2624 case mf225:
2625 case mf226:
2626 case mf227:
2627 case mf228:
2628 case mf229:
2629 case mf230:
2630 case mf231:
2631 case mf232:
2632 case mf233:
2633 case mf234:
2634 case mf235:
2635 case mf236:
2636 case mf237:
2637 case mf238:
2638 case mf239:
2639 case mf240:
2640 case mf241:
2641 case mf242:
2642 case mf243:
2643 case mf244:
2644 case mf245:
2645 case mf246:
2646 case mf247:
2647 case mf248:
2648 case mf249:
2649 case mf250:
2650 case mf251:
2651 case mf252:
2652 case mf253:
2653 case mf254:
2654 case mfEXTENDED:
2655 2997346 break;
2656
2657 case mfPUSHUD:
2658 case mfPUSHLR:
2659 case mfPUSH4:
2660 case mfPUSHU:
2661 case mfPUSHD:
2662 case mfPUSHL:
2663 case mfPUSHR:
2664 case mfPUSHUDNS:
2665 case mfPUSHLRNS:
2666 case mfPUSH4NS:
2667 case mfPUSHUNS:
2668 case mfPUSHDNS:
2669 case mfPUSHLNS:
2670 case mfPUSHRNS:
2671 case mfPUSHUDINS:
2672 case mfPUSHLRINS:
2673 case mfPUSH4INS:
2674 case mfPUSHUINS:
2675 case mfPUSHDINS:
2676 case mfPUSHLINS:
2677 case mfPUSHRINS:
2678
3/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
2638 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2679
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2680 {
2681 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2682 }
2683
2684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2638 times.
2638 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2685
3/6
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 1488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1488 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2638 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2686 {
2687
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 575 times.
1150 if(hints)
2688 {
2689
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 485 times.
575 switch(combobuf[tmpscr->data[i]].type)
2690 {
2691 case cPUSH_HEAVY:
2692 case cPUSH_HW:
2693 48 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2694 48 tempitemx=x, tempitemy=y;
2695
2696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(tempitem>-1)
2697 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2698
2699 48 break;
2700
2701 case cPUSH_HEAVY2:
2702 case cPUSH_HW2:
2703 42 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2704 42 tempitemx=x, tempitemy=y;
2705
2706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(tempitem>-1)
2707 42 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2708
2709 42 break;
2710 }
2711 575 }
2712 1150 }
2713
2714 2638 break;
2715
2716 case mfWHISTLE:
2717 if(hints)
2718 {
2719 tempitem=getItemID(itemsbuf,itype_whistle,1);
2720
2721 if(tempitem<0) break;
2722
2723 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2724 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2725 {
2726 tempitemx=x;
2727 tempitemy=y;
2728 }
2729
2730 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2731 }
2732
2733 break;
2734
2735 //Why is this here?
2736 case mfFAIRY:
2737 case mfMAGICFAIRY:
2738 case mfALLFAIRY:
2739 if(hints)
2740 {
2741 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2742
2743 if(tempitem < 0) break;
2744
2745 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2746 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2747 {
2748 tempitemx=x;
2749 tempitemy=y;
2750 }
2751
2752 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2753 }
2754
2755 break;
2756
2757 case mfBCANDLE:
2758
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2759 {
2760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2761 252 }
2762 else
2763 {
2764 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2765
2766
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2767
2768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2769
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2770 {
2771 126 tempitemx=x;
2772 126 tempitemy=y;
2773 126 }
2774
2775 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2776 }
2777
2778 504 break;
2779
2780 case mfRCANDLE:
2781 if(!hints)
2782 {
2783 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2784 }
2785 else
2786 {
2787 tempitem=getItemID(itemsbuf,itype_candle,2);
2788
2789 if(tempitem<0) break;
2790
2791 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2792 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2793 {
2794 tempitemx=x;
2795 tempitemy=y;
2796 }
2797
2798 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2799 }
2800
2801 break;
2802
2803 case mfWANDFIRE:
2804 if(!hints)
2805 {
2806 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2807 }
2808 else
2809 {
2810 tempitem=getItemID(itemsbuf,itype_wand,1);
2811
2812 if(tempitem<0) break;
2813
2814 tempweapon=wFire;
2815
2816 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2817 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2818 {
2819 tempitemx=x;
2820 tempitemy=y;
2821 }
2822 else
2823 {
2824 tempweaponx=x;
2825 tempweapony=y;
2826 }
2827
2828 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfDINSFIRE:
2835 if(!hints)
2836 {
2837 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2838 }
2839 else
2840 {
2841 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2842
2843 if(tempitem<0) break;
2844
2845 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 tempitemx=x;
2849 tempitemy=y;
2850 }
2851
2852 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 break;
2856
2857 case mfARROW:
2858
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 36 times.
118 if(!hints)
2859 {
2860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2861 36 }
2862 else
2863 {
2864 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2865
2866
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2867
2868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869
3/6
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 42 tempitemx=x;
2872 42 tempitemy=y;
2873 42 }
2874
2875 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 118 break;
2879
2880 case mfSARROW:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_arrow,2);
2888
2889 if(tempitem<0) break;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897
2898 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2899 }
2900
2901 break;
2902
2903 case mfGARROW:
2904 if(!hints)
2905 {
2906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2907 }
2908 else
2909 {
2910 tempitem=getItemID(itemsbuf,itype_arrow,3);
2911
2912 if(tempitem<0) break;
2913
2914 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2915 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2916 {
2917 tempitemx=x;
2918 tempitemy=y;
2919 }
2920
2921 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2922 }
2923
2924 break;
2925
2926 case mfBOMB:
2927
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
2928 {
2929 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2930 }
2931 else
2932 {
2933 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2934 17 tempweapon = wLitBomb;
2935
2936 //if (tempitem<0) break;
2937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2938
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2939 {
2940 8 tempweaponx=x;
2941 8 tempweapony=y;
2942 8 }
2943
2944 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2945 }
2946
2947 17 break;
2948
2949 case mfSBOMB:
2950
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2951 {
2952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2953 48 }
2954 else
2955 {
2956 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2957 //if (tempitem<0) break;
2958 48 tempweapon = wLitSBomb;
2959
2960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2961
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2962 {
2963 24 tempweaponx=x;
2964 24 tempweapony=y;
2965 24 }
2966
2967 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2968 }
2969
2970 96 break;
2971
2972 case mfARMOS_SECRET:
2973
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2974 {
2975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2976 12 }
2977 24 break;
2978
2979 case mfBRANG:
2980
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2983 }
2984 else
2985 {
2986 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2987
2988
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2989
2990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 3 tempitemx=x;
2994 3 tempitemy=y;
2995 3 }
2996
2997 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2998 }
2999
3000 5 break;
3001
3002 case mfMBRANG:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3006 }
3007 else
3008 {
3009 tempitem=getItemID(itemsbuf,itype_brang,2);
3010
3011 if(tempitem<0) break;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempitemx=x;
3017 tempitemy=y;
3018 }
3019
3020 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3021 }
3022
3023 break;
3024
3025 case mfFBRANG:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3029 }
3030 else
3031 {
3032 tempitem=getItemID(itemsbuf,itype_brang,3);
3033
3034 if(tempitem<0) break;
3035
3036 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3037 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3038 {
3039 tempitemx=x;
3040 tempitemy=y;
3041 }
3042
3043 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3044 }
3045
3046 break;
3047
3048 case mfWANDMAGIC:
3049 if(!hints)
3050 {
3051 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3052 }
3053 else
3054 {
3055 tempitem=getItemID(itemsbuf,itype_wand,1);
3056
3057 if(tempitem<0) break;
3058
3059 tempweapon=itemsbuf[tempitem].wpn3;
3060
3061 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3062 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3063 {
3064 tempitemx=x;
3065 tempitemy=y;
3066 }
3067 else
3068 {
3069 tempweaponx=x;
3070 tempweapony=y;
3071 --lens_hint_weapon[wMagic][4];
3072
3073 if(lens_hint_weapon[wMagic][4]<-8)
3074 {
3075 lens_hint_weapon[wMagic][4]=8;
3076 }
3077 }
3078
3079 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3080 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3081 }
3082
3083 break;
3084
3085 case mfREFMAGIC:
3086
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3089 }
3090 else
3091 {
3092 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3093
3094
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3095
3096 16 tempweapon=ewMagic;
3097
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3099
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3100 {
3101 8 tempitemx=x;
3102 8 tempitemy=y;
3103 8 }
3104 else
3105 {
3106 8 tempweaponx=x;
3107 8 tempweapony=y;
3108
3109
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(lens_hint_weapon[ewMagic][2]==up)
3110 {
3111 1 --lens_hint_weapon[ewMagic][4];
3112 1 }
3113 else
3114 {
3115 7 ++lens_hint_weapon[ewMagic][4];
3116 }
3117
3118
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewMagic][4]>8)
3119 {
3120 lens_hint_weapon[ewMagic][2]=up;
3121 }
3122
3123
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(lens_hint_weapon[ewMagic][4]<=0)
3124 {
3125 2 lens_hint_weapon[ewMagic][2]=down;
3126 2 }
3127 }
3128
3129 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3130 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3131 }
3132
3133 16 break;
3134
3135 case mfREFFIREBALL:
3136
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3137 {
3138 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3139 }
3140 else
3141 {
3142 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3143
3144
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3145
3146 16 tempweapon=ewFireball;
3147
3148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3149
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3150 {
3151 8 tempitemx=x;
3152 8 tempitemy=y;
3153 8 tempweaponx=x;
3154 8 tempweapony=y;
3155 8 ++lens_hint_weapon[ewFireball][3];
3156
3157
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>8)
3158 {
3159 lens_hint_weapon[ewFireball][3]=-8;
3160 lens_hint_weapon[ewFireball][4]=8;
3161 }
3162
3163
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(lens_hint_weapon[ewFireball][3]>0)
3164 {
3165 8 ++lens_hint_weapon[ewFireball][4];
3166 8 }
3167 else
3168 {
3169 --lens_hint_weapon[ewFireball][4];
3170 }
3171 8 }
3172
3173 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3174 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3175 }
3176
3177 16 break;
3178
3179 case mfSWORD:
3180
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3181 {
3182 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3183 }
3184 else
3185 {
3186 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3187
3188
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3189
3190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3191
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3192 {
3193 3 tempitemx=x;
3194 3 tempitemy=y;
3195 3 }
3196
3197 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3198 }
3199
3200 7 break;
3201
3202 case mfWSWORD:
3203 if(!hints)
3204 {
3205 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3206 }
3207 else
3208 {
3209 tempitem=getItemID(itemsbuf,itype_sword,2);
3210
3211 if(tempitem<0) break;
3212
3213 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3214 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3215 {
3216 tempitemx=x;
3217 tempitemy=y;
3218 }
3219
3220 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3221 }
3222
3223 break;
3224
3225 case mfMSWORD:
3226 if(!hints)
3227 {
3228 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3229 }
3230 else
3231 {
3232 tempitem=getItemID(itemsbuf,itype_sword,3);
3233
3234 if(tempitem<0) break;
3235
3236 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3237 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3238 {
3239 tempitemx=x;
3240 tempitemy=y;
3241 }
3242
3243 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3244 }
3245
3246 break;
3247
3248 case mfXSWORD:
3249 if(!hints)
3250 {
3251 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3252 }
3253 else
3254 {
3255 tempitem=getItemID(itemsbuf,itype_sword,4);
3256
3257 if(tempitem<0) break;
3258
3259 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3260 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3261 {
3262 tempitemx=x;
3263 tempitemy=y;
3264 }
3265
3266 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3267 }
3268
3269 break;
3270
3271 case mfSWORDBEAM:
3272
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3273 {
3274 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3275 }
3276 else
3277 {
3278 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3279
3280
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3281
3282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3283
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3284 {
3285 8 tempitemx=x;
3286 8 tempitemy=y;
3287 8 }
3288
3289 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3290 }
3291
3292 16 break;
3293
3294 case mfWSWORDBEAM:
3295 if(!hints)
3296 {
3297 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3298 }
3299 else
3300 {
3301 tempitem=getItemID(itemsbuf,itype_sword,2);
3302
3303 if(tempitem<0) break;
3304
3305 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3306 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3307 {
3308 tempitemx=x;
3309 tempitemy=y;
3310 }
3311
3312 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3313 }
3314
3315 break;
3316
3317 case mfMSWORDBEAM:
3318 if(!hints)
3319 {
3320 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3321 }
3322 else
3323 {
3324 tempitem=getItemID(itemsbuf,itype_sword,3);
3325
3326 if(tempitem<0) break;
3327
3328 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3329 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3330 {
3331 tempitemx=x;
3332 tempitemy=y;
3333 }
3334
3335 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3336 }
3337
3338 break;
3339
3340 case mfXSWORDBEAM:
3341 if(!hints)
3342 {
3343 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3344 }
3345 else
3346 {
3347 tempitem=getItemID(itemsbuf,itype_sword,4);
3348
3349 if(tempitem<0) break;
3350
3351 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3352 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3353 {
3354 tempitemx=x;
3355 tempitemy=y;
3356 }
3357
3358 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3359 }
3360
3361 break;
3362
3363 case mfHOOKSHOT:
3364
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3365 {
3366 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3367 }
3368 else
3369 {
3370 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3371
3372
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3373
3374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3375
3/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3376 {
3377 9 tempitemx=x;
3378 9 tempitemy=y;
3379 9 }
3380
3381 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3382 }
3383
3384 17 break;
3385
3386 case mfWAND:
3387
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3388 {
3389 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3390 }
3391 else
3392 {
3393 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3394
3395
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3396
3397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3398
3/6
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3399 {
3400 17 tempitemx=x;
3401 17 tempitemy=y;
3402 17 }
3403
3404 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3405 }
3406
3407 35 break;
3408
3409 case mfHAMMER:
3410
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3411 {
3412 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3413 }
3414 else
3415 {
3416 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3417
3418
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3419
3420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3421
3/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3422 {
3423 8 tempitemx=x;
3424 8 tempitemy=y;
3425 8 }
3426
3427 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3428 }
3429
3430 17 break;
3431
3432 case mfARMOS_ITEM:
3433 case mfDIVE_ITEM:
3434
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3435 {
3436 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3437 2064 }
3438 2064 break;
3439
3440 case 16:
3441 case 17:
3442 case 18:
3443 case 19:
3444 case 20:
3445 case 21:
3446 case 22:
3447 case 23:
3448 case 24:
3449 case 25:
3450 case 26:
3451 case 27:
3452 case 28:
3453 case 29:
3454 case 30:
3455 case 31:
3456
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 1008 times.
2016 if(!hints)
3457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1008 times.
2016 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3458 1008 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3459
3460 2016 break;
3461 case mfSECRETSNEXT:
3462 if(!hints)
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3464 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3465
3466 break;
3467
3468 case mfSTRIKE:
3469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3470 {
3471 192 goto special;
3472 }
3473 else
3474 {
3475 break;
3476 }
3477
3478 28392 default: goto special;
3479
3480 special:
3481
8/8
✓ Branch 0 taken 14196 times.
✓ Branch 1 taken 14388 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 14088 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8004 times.
28584 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3482 {
3483
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
✓ Branch 2 taken 3096 times.
✓ Branch 3 taken 3096 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3096 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6192 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3484 {
3485 3096 rectfill(dest,x,y,x+15,y+15,WHITE);
3486 3096 }
3487 6192 }
3488
3489 28584 break;
3490 }
3491 3033536 }
3492 1516768 }
3493
3494
2/2
✓ Branch 0 taken 4309 times.
✓ Branch 1 taken 4309 times.
8618 if(layer)
3495 {
3496
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 108 times.
4309 if(tmpscr->door[0]==dWALK)
3497 108 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3498
3499
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 108 times.
4309 if(tmpscr->door[1]==dWALK)
3500 108 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3501
3502
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[2]==dWALK)
3503 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3504
3505
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[3]==dWALK)
3506 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3507
3508
2/2
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 24 times.
4309 if(tmpscr->door[0]==dBOMB)
3509 {
3510 24 showbombeddoor(dest, 0);
3511 24 }
3512
3513
2/2
✓ Branch 0 taken 4285 times.
✓ Branch 1 taken 24 times.
4309 if(tmpscr->door[1]==dBOMB)
3514 {
3515 24 showbombeddoor(dest, 1);
3516 24 }
3517
3518
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[2]==dBOMB)
3519 {
3520 showbombeddoor(dest, 2);
3521 }
3522
3523
1/2
✓ Branch 0 taken 4309 times.
✗ Branch 1 not taken.
4309 if(tmpscr->door[3]==dBOMB)
3524 {
3525 showbombeddoor(dest, 3);
3526 }
3527 4309 }
3528
3529
2/2
✓ Branch 0 taken 6796 times.
✓ Branch 1 taken 1822 times.
8618 if(tmpscr->stairx + tmpscr->stairy)
3530 {
3531
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 911 times.
1822 if(!hints)
3532 {
3533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 911 times.
911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3534 911 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3535 911 }
3536 else
3537 {
3538
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3539 {
3540 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3541 48 int32_t tempitemx=-16;
3542 48 int32_t tempitemy=-16;
3543
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3545
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3546 {
3547 tempitemx=tmpscr->stairx;
3548 tempitemy=tmpscr->stairy+playing_field_offset;
3549 }
3550
3551 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3552 48 }
3553 }
3554 1822 }
3555 }
3556 8618 }
3557
3558 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3559
3560 4140 void draw_lens_over()
3561 {
3562 // Oh, what the heck.
3563 static BITMAP *lens_scr = NULL;
3564 static int32_t last_width = -1;
3565 4140 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3566
3567 // Only redraw the circle if the size has changed
3568
2/2
✓ Branch 0 taken 4138 times.
✓ Branch 1 taken 2 times.
4140 if(width != last_width)
3569 {
3570
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(lens_scr == NULL)
3571 {
3572 2 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3573 2 }
3574
3575 2 clear_to_color(lens_scr, BLACK);
3576 2 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3577 2 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3578 2 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3579 2 last_width=width;
3580 2 }
3581
3582 4140 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3583 4140 }
3584
3585 //----------------------------------------------------------------
3586
3587 7245 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3588 {
3589 //recreating a big bitmap every frame is highly sluggish.
3590
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7244 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
7245 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3591 7245 clear_to_color(wavebuf, BLACK);
3592 7245 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3593
3594 int32_t ofs;
3595 // int32_t amplitude=8;
3596 // int32_t wavelength=4;
3597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7245 times.
7245 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3598
2/6
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7245 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3599 7245 int32_t amp2=168;
3600
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7245 times.
✗ Branch 3 not taken.
7245 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3601 7245 int32_t i=frame%amp2;
3602
3603
2/2
✓ Branch 0 taken 1217160 times.
✓ Branch 1 taken 7245 times.
1224405 for(int32_t j=0; j<168; j++)
3604 {
3605
3/4
✓ Branch 0 taken 608580 times.
✓ Branch 1 taken 608580 times.
✓ Branch 2 taken 608580 times.
✗ Branch 3 not taken.
1217160 if(j&1 && interpol)
3606 {
3607 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3608 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3609 }
3610 else
3611 {
3612 1217160 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3613 }
3614
3615
1/2
✓ Branch 0 taken 1217160 times.
✗ Branch 1 not taken.
1217160 if(ofs)
3616 {
3617
2/2
✓ Branch 0 taken 311592960 times.
✓ Branch 1 taken 1217160 times.
312810120 for(int32_t k=0; k<256; k++)
3618 {
3619 311592960 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3620 311592960 }
3621 1217160 }
3622 1217160 }
3623 7245 }
3624
3625 576 void draw_fuzzy(int32_t fuzz)
3626 // draws from right half of scrollbuf to framebuf
3627 {
3628 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3629 byte *start, *si, *di;
3630
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(fuzz<1)
3632 fuzz = 1;
3633
3634 576 xstep = 128%fuzz;
3635
3636
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 456 times.
576 if(xstep > 0)
3637 456 xstep = fuzz-xstep;
3638
3639 576 ystep = 112%fuzz;
3640
3641
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 408 times.
576 if(ystep > 0)
3642 408 ystep = fuzz-ystep;
3643
3644 576 firsty = 1;
3645
3646
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 20784 times.
21360 for(y=0; y<224;)
3647 {
3648 20784 start = &(scrollbuf->line[y][256]);
3649
3650
4/4
✓ Branch 0 taken 20496 times.
✓ Branch 1 taken 129312 times.
✓ Branch 2 taken 129024 times.
✓ Branch 3 taken 20784 times.
149808 for(dy=0; dy<ystep && dy+y<224; dy++)
3651 {
3652 129024 si = start;
3653 129024 di = &(framebuf->line[y+dy][0]);
3654 129024 i = xstep;
3655 129024 firstx = 1;
3656
3657
2/2
✓ Branch 0 taken 33030144 times.
✓ Branch 1 taken 129024 times.
33159168 for(dx=0; dx<256; dx++)
3658 {
3659 33030144 *(di++) = *si;
3660
3661
2/2
✓ Branch 0 taken 27831552 times.
✓ Branch 1 taken 5198592 times.
33030144 if(++i >= fuzz)
3662 {
3663
2/2
✓ Branch 0 taken 5069568 times.
✓ Branch 1 taken 129024 times.
5198592 if(!firstx)
3664 5069568 si += fuzz;
3665 else
3666 {
3667 129024 si += fuzz-xstep;
3668 129024 firstx = 0;
3669 }
3670
3671 5198592 i = 0;
3672 5198592 }
3673 33030144 }
3674 129024 }
3675
3676
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 576 times.
20784 if(!firsty)
3677 20208 y += fuzz;
3678 else
3679 {
3680 576 y += ystep;
3681 576 ystep = fuzz;
3682 576 firsty = 0;
3683 }
3684 }
3685 576 }
3686
3687 4109618 void updatescr(bool allowwavy)
3688 {
3689
4/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 4109603 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
4109618 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3690
4/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 4109603 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
4109618 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3691
3692
2/2
✓ Branch 0 taken 4083915 times.
✓ Branch 1 taken 25703 times.
4109618 if(toogam)
3693 {
3694 25703 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3695 25703 }
3696
3697
1/2
✓ Branch 0 taken 4109618 times.
✗ Branch 1 not taken.
4109618 if(Showpal)
3698 dump_pal(framebuf);
3699
3700
2/2
✓ Branch 0 taken 4050293 times.
✓ Branch 1 taken 59325 times.
4109618 if(!Playing)
3701 59325 black_opening_count=0;
3702
3703
2/2
✓ Branch 0 taken 4089620 times.
✓ Branch 1 taken 19998 times.
4109618 if(black_opening_count<0) //shape is opening up
3704 {
3705 19998 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3706
3707
2/4
✓ Branch 0 taken 19998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19998 times.
19998 if(Advance||(!Paused))
3708 {
3709 19998 ++black_opening_count;
3710 19998 }
3711 19998 }
3712
2/2
✓ Branch 0 taken 4080380 times.
✓ Branch 1 taken 9240 times.
4089620 else if(black_opening_count>0) //shape is closing
3713 {
3714 9240 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3715
3716
2/4
✓ Branch 0 taken 9240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9240 times.
9240 if(Advance||(!Paused))
3717 {
3718 9240 --black_opening_count;
3719 9240 }
3720 9240 }
3721
3722
3/4
✓ Branch 0 taken 4080823 times.
✓ Branch 1 taken 28795 times.
✓ Branch 2 taken 4080823 times.
✗ Branch 3 not taken.
4109618 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3723 {
3724 black_opening_shape = bosCIRCLE;
3725 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3726 refreshTints();
3727 refreshpal=true;
3728 }
3729
3730
2/2
✓ Branch 0 taken 4006559 times.
✓ Branch 1 taken 103059 times.
4109618 if(refreshpal)
3731 {
3732 103059 refreshpal=false;
3733 103059 RAMpal[253] = _RGB(0,0,0);
3734 103059 RAMpal[254] = _RGB(63,63,63);
3735 103059 hw_palette = &RAMpal;
3736 103059 update_hw_pal = true;
3737
3738 103059 create_rgb_table(&rgb_table, RAMpal, NULL);
3739 103059 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3740 103059 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3741
3742
2/2
✓ Branch 0 taken 26383104 times.
✓ Branch 1 taken 103059 times.
26486163 for(int32_t q=0; q<PAL_SIZE; q++)
3743 {
3744 26383104 trans_table2.data[0][q] = q;
3745 26383104 trans_table2.data[q][q] = q;
3746 26383104 }
3747 103059 }
3748
3749 4109618 bool clearwavy = (wavy <= 0);
3750
3751
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4102373 times.
4109618 if(wavy <= 0)
3752 {
3753 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3754 4102373 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3755 4102373 }
3756
3757 4109618 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3758
3759
4/6
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4102373 times.
✓ Branch 2 taken 7245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7245 times.
4109618 if(wavy && Playing && allowwavy)
3760 {
3761 7245 draw_wavy(framebuf, wavybuf, wavy,false);
3762 7245 }
3763
3764
2/2
✓ Branch 0 taken 4102373 times.
✓ Branch 1 taken 7245 times.
4109618 if(clearwavy)
3765 4102373 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3766
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3767 7245 wavy--; // Wavy was set by a script. Decrement it.
3768
3769
5/6
✓ Branch 0 taken 4050293 times.
✓ Branch 1 taken 59325 times.
✓ Branch 2 taken 77578 times.
✓ Branch 3 taken 3972715 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 77578 times.
4109618 if(Playing && msgpos && !screenscrolling)
3770 {
3771
1/2
✓ Branch 0 taken 77578 times.
✗ Branch 1 not taken.
77578 if(!(msg_bg_display_buf->clip))
3772 77578 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3773
1/2
✓ Branch 0 taken 77578 times.
✗ Branch 1 not taken.
77578 if(!(msg_portrait_display_buf->clip))
3774 77578 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3775
1/2
✓ Branch 0 taken 77578 times.
✗ Branch 1 not taken.
77578 if(!(msg_txt_display_buf->clip))
3776 77578 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3777 77578 }
3778
3779 /*
3780 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3781 {
3782 BITMAP* subBmp = 0;
3783 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3784 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3785 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3786 destroy_bitmap(subBmp);
3787 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3788 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3789 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3790 }
3791 */
3792
3793
2/2
✓ Branch 0 taken 4099329 times.
✓ Branch 1 taken 10289 times.
4109618 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3794
3795
2/2
✓ Branch 0 taken 4099329 times.
✓ Branch 1 taken 10289 times.
4109618 if(nosubscr)
3796 {
3797 10289 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3798 10289 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3799 10289 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3800 10289 }
3801
3802 //TODO: Optimize blit 'overcalls' -Gleeok
3803
2/2
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 4099329 times.
4109618 BITMAP *source = nosubscr ? panorama : wavybuf;
3804 4109618 blit(source,framebuf,0,0,0,0,256,224);
3805
3806 4109618 update_hw_screen();
3807 4109618 }
3808
3809 //----------------------------------------------------------------
3810
3811 PALETTE sys_pal;
3812
3813 int32_t onGUISnapshot()
3814 {
3815 char buf[200];
3816 int32_t num=0;
3817 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3818 do
3819 {
3820 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3821 }
3822 while(num<99999 && exists(buf));
3823
3824 BITMAP *b = create_bitmap_ex(8,resx,resy);
3825
3826 if(b)
3827 {
3828 if(MenuOpen)
3829 {
3830 //Cannot load game's palette while GUI elements are in focus. -Z
3831 //If there is a way to do this, then I have missed it.
3832 /*
3833 game_pal();
3834 RAMpal[253] = _RGB(0,0,0);
3835 RAMpal[254] = _RGB(63,63,63);
3836 set_palette_range(RAMpal,0,255,false);
3837 memcpy(RAMpal, snappal, sizeof(snappal));
3838 create_rgb_table(&rgb_table, RAMpal, NULL);
3839 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3840 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3841
3842 for(int32_t q=0; q<PAL_SIZE; q++)
3843 {
3844 trans_table2.data[0][q] = q;
3845 trans_table2.data[q][q] = q;
3846 }
3847 */
3848 //ringcolor(false);
3849 //get_palette(RAMpal);
3850 blit(screen,b,0,0,0,0,resx,resy);
3851 //al_trace("Menu Open\n");
3852 //game_pal();
3853 //PALETTE temppal;
3854 //get_palette(temppal);
3855 //system_pal();
3856 save_bitmap(buf,b,sys_pal);
3857 //save_bitmap(buf,b,RAMpal);
3858 //save_bitmap(buf,b,snappal);
3859 }
3860 else
3861 {
3862 blit(screen,b,0,0,0,0,resx,resy);
3863 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3864 }
3865 destroy_bitmap(b);
3866 }
3867
3868 return D_O_K;
3869 }
3870
3871 int32_t onNonGUISnapshot()
3872 {
3873 PALETTE temppal;
3874 get_palette(temppal);
3875 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3876
3877 char buf[200];
3878 int32_t num=0;
3879
3880 do
3881 {
3882 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3883 }
3884 while(num<99999 && exists(buf));
3885
3886 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3887
3888 return D_O_K;
3889 }
3890
3891 int32_t onSnapshot()
3892 {
3893 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3894 {
3895 onGUISnapshot();
3896 }
3897 else
3898 {
3899 onNonGUISnapshot();
3900 }
3901
3902 return D_O_K;
3903 }
3904
3905 int32_t onSaveMapPic()
3906 {
3907 int32_t mapres2 = 0;
3908 char buf[200];
3909 int32_t num=0;
3910 mapscr tmpscr_b[2];
3911 mapscr tmpscr_c[6];
3912 BITMAP* _screen_draw_buffer = NULL;
3913 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3914 set_clip_state(_screen_draw_buffer,1);
3915
3916 for(int32_t i=0; i<6; ++i)
3917 {
3918 tmpscr_c[i] = tmpscr2[i];
3919 tmpscr2[i].zero_memory();
3920
3921 if(i>=2)
3922 {
3923 continue;
3924 }
3925
3926 tmpscr_b[i] = tmpscr[i];
3927 tmpscr[i].zero_memory();
3928 }
3929
3930 do
3931 {
3932 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3933 }
3934 while(num<99999 && exists(buf));
3935
3936 BITMAP* mappic = NULL;
3937
3938
3939 bool done=false, redraw=true;
3940
3941 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3942
3943 if(!mappic)
3944 {
3945 system_pal();
3946 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3947 game_pal();
3948 return D_O_K;;
3949 }
3950
3951 // draw the map
3952 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3953
3954 for(int32_t y=0; y<8; y++)
3955 {
3956 for(int32_t x=0; x<16; x++)
3957 {
3958 if(!displayOnMap(x, y))
3959 {
3960 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3961 }
3962 else
3963 {
3964 int32_t s = (y<<4) + x;
3965 loadscr2(1,s,-1);
3966
3967 for(int32_t i=0; i<6; i++)
3968 {
3969 if(tmpscr[1].layermap[i]<=0)
3970 continue;
3971
3972 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
3973 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
3974 {
3975 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
3976
3977 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3978 }
3979 }
3980
3981 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3982
3983 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3984
3985 putscr(_screen_draw_buffer,256,0,tmpscr+1);
3986 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3987
3988 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3989
3990 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3991 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3992 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
3993 {
3994 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3995 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3996 }
3997 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3998
3999 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4000
4001 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4002 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4003 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4004 {
4005 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4006 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4007 }
4008 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4009 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4010
4011 }
4012
4013 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4014 }
4015 }
4016
4017 for(int32_t i=0; i<6; ++i)
4018 {
4019 tmpscr2[i]=tmpscr_c[i];
4020
4021 if(i>=2)
4022 {
4023 continue;
4024 }
4025
4026 tmpscr[i]=tmpscr_b[i];
4027 }
4028
4029 save_bitmap(buf,mappic,RAMpal);
4030 destroy_bitmap(mappic);
4031 destroy_bitmap(_screen_draw_buffer);
4032 return D_O_K;
4033 }
4034
4035 /*
4036 int32_t onSaveMapPic()
4037 {
4038 BITMAP* mappic = NULL;
4039 BITMAP* _screen_draw_buffer = NULL;
4040 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4041 int32_t mapres2 = 0;
4042 char buf[20];
4043 int32_t num=0;
4044 set_clip_state(_screen_draw_buffer,1);
4045 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4046
4047 do
4048 {
4049 sprintf(buf, "zelda%03d.png", ++num);
4050 }
4051 while(num<999 && exists(buf));
4052
4053 // if(!mappic) {
4054 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4055
4056 if(!mappic)
4057 {
4058 system_pal();
4059 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4060 game_pal();
4061 return D_O_K;
4062 }
4063
4064 // }
4065
4066 int32_t layermap, layerscreen;
4067 int32_t x2=0;
4068
4069 // draw the map
4070 for(int32_t y=0; y<8; y++)
4071 {
4072 for(int32_t x=0; x<16; x++)
4073 {
4074 int32_t s = (y<<4) + x;
4075
4076 if(!displayOnMap(x, y))
4077 {
4078 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4079 }
4080 else
4081 {
4082 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4083 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4084
4085 for(int32_t k=0; k<4; k++)
4086 {
4087 if(k==2)
4088 {
4089 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4090 }
4091
4092 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4093
4094 if(layermap>-1)
4095 {
4096 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4097
4098 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4099 {
4100 for(int32_t i=0; i<176; i++)
4101 {
4102 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4103 }
4104 }
4105 else
4106 {
4107 for(int32_t i=0; i<176; i++)
4108 {
4109 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4110 }
4111 }
4112 }
4113 }
4114
4115 for(int32_t i=0; i<176; i++)
4116 {
4117 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4118 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4119 {
4120 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4121 }
4122 }
4123
4124 for(int32_t k=4; k<6; k++)
4125 {
4126 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4127
4128 if(layermap>-1)
4129 {
4130 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4131
4132 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4133 {
4134 for(int32_t i=0; i<176; i++)
4135 {
4136 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4137 }
4138 }
4139 else
4140 {
4141 for(int32_t i=0; i<176; i++)
4142 {
4143 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4144 }
4145 }
4146 }
4147 }
4148 }
4149
4150 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4151 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4152 }
4153
4154 }
4155
4156 save_bitmap(buf,mappic,RAMpal);
4157 destroy_bitmap(mappic);
4158 destroy_bitmap(_screen_draw_buffer);
4159 return D_O_K;
4160 }
4161 */
4162
4163 14 void f_Quit(int32_t type)
4164 {
4165
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4166 return;
4167
4168 14 bool from_menu = is_sys_pal;
4169
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4171 {
4172 14 music_pause();
4173 14 pause_all_sfx();
4174 14 }
4175 14 enter_sys_pal();
4176 14 clear_keybuf();
4177
4178 14 replay_poll();
4179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4180 14 replay_peek_quit();
4181
4182
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4183 switch(type)
4184 {
4185 case qQUIT:
4186 onQuit();
4187 break;
4188
4189 case qRESET:
4190 onReset();
4191 break;
4192
4193 case qEXIT:
4194 onExit();
4195 break;
4196 }
4197
4198
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4199 {
4200 14 kill_sfx();
4201 14 music_stop();
4202 14 exit_sys_pal();
4203 14 update_hw_screen();
4204 14 }
4205 else
4206 {
4207 exit_sys_pal();
4208 if(!from_menu)
4209 {
4210 music_resume();
4211 resume_all_sfx();
4212 }
4213 }
4214
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4216 14 show_mouse(NULL);
4217 14 eat_buttons();
4218
4219 14 zc_readrawkey(KEY_ESC);
4220
4221 14 zc_readrawkey(KEY_ENTER);
4222 14 }
4223
4224 //----------------------------------------------------------------
4225
4226 int32_t onNoWalls()
4227 {
4228 cheats_enqueue(Cheat::Walls);
4229 return D_O_K;
4230 }
4231
4232 int32_t onIgnoreSideview()
4233 {
4234 cheats_enqueue(Cheat::IgnoreSideView);
4235 return D_O_K;
4236 }
4237
4238 4167328 int32_t input_idle(bool checkmouse)
4239 {
4240 static int32_t mx, my, mz, mb;
4241
4242
4/6
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 913084 times.
✓ Branch 3 taken 3254244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 913084 times.
5080412 if(keypressed() || zc_key_pressed() ||
4243
4/8
✓ Branch 0 taken 913084 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 913084 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 913084 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 913084 times.
✗ Branch 7 not taken.
913084 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4244 {
4245 3254244 idle_count = 0;
4246
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3254244 times.
3254244 if(active_count < MAX_ACTIVE)
4248 {
4249 3254244 ++active_count;
4250 3254244 }
4251 3254244 }
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 913084 times.
913084 else if(idle_count < MAX_IDLE)
4253 {
4254 913084 ++idle_count;
4255 913084 active_count = 0;
4256 913084 }
4257
4258 4167328 mx = mouse_x;
4259 4167328 my = mouse_y;
4260 4167328 mz = mouse_z;
4261 4167328 mb = mouse_b;
4262
4263 4167328 return idle_count;
4264 }
4265
4266 int32_t onGoFast()
4267 {
4268 cheats_enqueue(Cheat::Fast);
4269 return D_O_K;
4270 }
4271
4272 int32_t onKillCheat()
4273 {
4274 cheats_enqueue(Cheat::Kill);
4275 return D_O_K;
4276 }
4277
4278 int32_t onShowLayer0()
4279 {
4280 show_layer_0 = !show_layer_0;
4281 return D_O_K;
4282 }
4283 int32_t onShowLayer1()
4284 {
4285 show_layer_1 = !show_layer_1;
4286 return D_O_K;
4287 }
4288 int32_t onShowLayer2()
4289 {
4290 show_layer_2 = !show_layer_2;
4291 return D_O_K;
4292 }
4293 int32_t onShowLayer3()
4294 {
4295 show_layer_3 = !show_layer_3;
4296 return D_O_K;
4297 }
4298 int32_t onShowLayer4()
4299 {
4300 show_layer_4 = !show_layer_4;
4301 return D_O_K;
4302 }
4303 int32_t onShowLayer5()
4304 {
4305 show_layer_5 = !show_layer_5;
4306 return D_O_K;
4307 }
4308 int32_t onShowLayer6()
4309 {
4310 show_layer_6 = !show_layer_6;
4311 return D_O_K;
4312 }
4313 int32_t onShowLayerO()
4314 {
4315 show_layer_over=!show_layer_over;
4316 return D_O_K;
4317 }
4318 int32_t onShowLayerP()
4319 {
4320 show_layer_push=!show_layer_push;
4321 return D_O_K;
4322 }
4323 int32_t onShowLayerS()
4324 {
4325 show_sprites=!show_sprites;
4326 return D_O_K;
4327 }
4328 int32_t onShowLayerF()
4329 {
4330 show_ffcs=!show_ffcs;
4331 return D_O_K;
4332 }
4333 int32_t onShowLayerW()
4334 {
4335 show_walkflags=!show_walkflags;
4336 return D_O_K;
4337 }
4338 int32_t onShowLayerE()
4339 {
4340 show_effectflags=!show_effectflags;
4341 return D_O_K;
4342 }
4343 int32_t onShowFFScripts()
4344 {
4345 show_ff_scripts=!show_ff_scripts;
4346 return D_O_K;
4347 }
4348 int32_t onShowHitboxes()
4349 {
4350 show_hitboxes=!show_hitboxes;
4351 return D_O_K;
4352 }
4353
4354 int32_t onLightSwitch()
4355 {
4356 cheats_enqueue(Cheat::Light);
4357 return D_O_K;
4358 }
4359
4360 int32_t onGoTo();
4361 int32_t onGoToComplete();
4362
4363 4167328 void syskeys()
4364 {
4365 4167328 update_system_keys();
4366
4367 int32_t oldtitle_version;
4368
4369
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(close_button_quit)
4370 {
4371 close_button_quit=false;
4372 f_Quit(qEXIT);
4373 }
4374
4375 4167328 poll_joystick();
4376
4377
2/10
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4167328 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4167328 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4378 {
4379 oldtitle_version=title_version;
4380 System();
4381 }
4382
4383 4167328 mouse_down=gui_mouse_b();
4384
4385
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(zc_read_system_key(KEY_F1))
4386 {
4387 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4388 {
4389 halt=!halt;
4390 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4391 }
4392 else
4393 {
4394 Throttlefps=!Throttlefps;
4395 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4396 logic_counter=0;
4397 }
4398 }
4399
4400 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4401 /*
4402 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4403 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4404 */
4405
4406
1/4
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4167328 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4407
4408
1/4
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4167328 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4409
4410
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(zc_read_system_key(KEY_F2))
4411 {
4412 ShowFPS=!ShowFPS;
4413 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4414 }
4415
4416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4167328 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4417
4418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4167328 if(zc_read_system_key(KEY_F4) && Playing)
4419 {
4420 Paused=true;
4421 Advance=true;
4422 }
4423
4424
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(zc_read_system_key(KEY_F6)) onTryQuit();
4425
4426 #ifndef ALLEGRO_MACOSX
4427
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4428
4429
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4430 #else
4431 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4432
4433 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4434 #endif
4435
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4167328 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4436
4437
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if (zc_read_system_key(KEY_F12))
4438 {
4439 onSnapshot();
4440 }
4441
4442
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4167328 if(debug_enabled && zc_read_system_key(KEY_TAB))
4443 set_debug(!get_debug());
4444
4445
3/4
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 4148598 times.
4167328 if(get_debug() || cheat>=1)
4446 {
4447
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4448 {
4449 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4450
4451 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4452
4453 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4454
4455 if(zc_readkey(KEY_B))
4456 {
4457 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4458 }
4459
4460 if(zc_readkey(KEY_A))
4461 {
4462 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4463 }
4464 }
4465 18730 }
4466
4467
3/4
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 4148598 times.
4167328 if(get_debug() || cheat>=2)
4468 {
4469
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4470 {
4471 if(rI())
4472 {
4473 cheats_enqueue(Cheat::Clock);
4474 }
4475 }
4476 18730 }
4477
4478
3/4
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18730 times.
✓ Branch 3 taken 4148598 times.
4167328 if(get_debug() || cheat>=4)
4479 {
4480
1/2
✓ Branch 0 taken 18730 times.
✗ Branch 1 not taken.
18730 if( CheatModifierKeys() )
4481 {
4482 if(rF11())
4483 {
4484 cheats_enqueue(Cheat::Walls);
4485 }
4486
4487 if(rQ())
4488 {
4489 cheats_enqueue(Cheat::Fast);
4490 }
4491
4492 if(zc_readkey(KEY_F))
4493 {
4494 cheats_enqueue(Cheat::Freeze);
4495 }
4496
4497 if(zc_readkey(KEY_G)) onGoToComplete();
4498
4499 if(zc_readkey(KEY_0)) onShowLayer0();
4500
4501 if(zc_readkey(KEY_1)) onShowLayer1();
4502
4503 if(zc_readkey(KEY_2)) onShowLayer2();
4504
4505 if(zc_readkey(KEY_3)) onShowLayer3();
4506
4507 if(zc_readkey(KEY_4)) onShowLayer4();
4508
4509 if(zc_readkey(KEY_5)) onShowLayer5();
4510
4511 if(zc_readkey(KEY_6)) onShowLayer6();
4512
4513 //if(zc_readkey(KEY_7)) onShowLayerO();
4514 if(zc_readkey(KEY_7)) onShowLayerF();
4515
4516 if(zc_readkey(KEY_8)) onShowLayerS();
4517
4518 if(zc_readkey(KEY_W)) onShowLayerW();
4519
4520 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4521
4522 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4523
4524 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4525 if(zc_readkey(KEY_O)) onShowLayerO();
4526 if(zc_readkey(KEY_P)) onShowLayerP();
4527 if(zc_readkey(KEY_C)) onShowHitboxes();
4528 if(zc_readkey(KEY_F)) onShowFFScripts();
4529 }
4530 18730 }
4531
4532
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(volkeys)
4533 {
4534 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4535
4536 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4537
4538 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4539
4540 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4541 }
4542
4543
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4167328 if(!get_debug() || !SystemKeys || replay_is_replaying())
4544 4167328 goto bottom;
4545
4546 if(zc_readkey(KEY_D))
4547 {
4548 details = !details;
4549 rectfill(screen,0,0,319,7,BLACK);
4550 rectfill(screen,0,8,31,239,BLACK);
4551 rectfill(screen,288,8,319,239,BLACK);
4552 rectfill(screen,32,232,287,239,BLACK);
4553 }
4554
4555 if(zc_readkey(KEY_P)) Paused=!Paused;
4556
4557 //if(zc_readkey(KEY_P)) centerHero();
4558 if(zc_readkey(KEY_A))
4559 {
4560 Paused=true;
4561 Advance=true;
4562 }
4563
4564 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4565 #ifndef ALLEGRO_MACOSX
4566 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4567
4568 if(zc_readkey(KEY_F7))
4569 {
4570 Matrix(ss_speed, ss_density, 0);
4571 game_pal();
4572 }
4573 #else
4574 // The reason these are different on Mac in the first place is that
4575 // the OS doesn't let us use F9 and F10...
4576 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4577
4578 if(zc_readkey(KEY_F9))
4579 {
4580 Matrix(ss_speed, ss_density, 0);
4581 game_pal();
4582 }
4583 #endif
4584 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4585 {
4586 //change containers
4587 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4588 {
4589 //magic containers
4590 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4591 {
4592 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4593 }
4594 else
4595 {
4596 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4597 }
4598 }
4599 else
4600 {
4601 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4602 {
4603 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4604 }
4605 else
4606 {
4607 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4608 }
4609 }
4610 }
4611
4612 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4613 {
4614 //change containers
4615 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4616 {
4617 //magic containers
4618 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4619 {
4620 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4621 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4622 //heart containers
4623 }
4624 else
4625 {
4626 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4627 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4628 }
4629 }
4630 else
4631 {
4632 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4633 {
4634 game->set_magic(zc_max(game->get_magic()-1,0));
4635 }
4636 else
4637 {
4638 game->set_life(zc_max(game->get_life()-1,0));
4639 }
4640 }
4641 }
4642
4643 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4644
4645 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4646
4647 verifyBothWeapons();
4648
4649 bottom:
4650
4651
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(input_idle(true) > after_time())
4652 {
4653 Matrix(ss_speed, ss_density, 0);
4654 game_pal();
4655 }
4656 4167328 }
4657
4658 13808302 void checkQuitKeys()
4659 {
4660 #ifndef ALLEGRO_MACOSX
4661
1/2
✓ Branch 0 taken 13808302 times.
✗ Branch 1 not taken.
13808302 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4662
4663
1/2
✓ Branch 0 taken 13808302 times.
✗ Branch 1 not taken.
13808302 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4664 #else
4665 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4666
4667 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4668 #endif
4669 13808302 }
4670
4671 56190 bool CheatModifierKeys()
4672 {
4673 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4674 // to trigger cheats.
4675
1/2
✓ Branch 0 taken 56190 times.
✗ Branch 1 not taken.
56190 if (replay_is_replaying())
4676 56190 return false;
4677
4678 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4679 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4680 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4681 {
4682 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4683 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4684 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4685 {
4686 return true;
4687 }
4688 }
4689 return false;
4690 56190 }
4691
4692 //99:05:54, for some reason?
4693 #define OLDMAXTIME 21405240
4694 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4695 #define MAXTIME 1944000000
4696
4697 4109640 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4698 {
4699
2/2
✓ Branch 0 taken 3848229 times.
✓ Branch 1 taken 261411 times.
4109640 if(zcmusic!=NULL)
4700 {
4701 261411 zcmusic_poll();
4702 261411 }
4703
4704
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4109640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4109640 times.
4109640 while(Paused && !Advance && !Quit)
4705 {
4706 // have to call this, otherwise we'll get an infinite loop
4707 syskeys();
4708 if(allowF6Script)
4709 {
4710 FFCore.runF6Engine();
4711 }
4712 if (replay_get_mode() != ReplayMode::Assert)
4713 updatescr(allowwavy);
4714 throttleFPS();
4715
4716 #ifdef _WIN32
4717
4718 if(use_dwm_flush)
4719 {
4720 do_DwmFlush();
4721 }
4722
4723 #endif
4724
4725 // to keep music playing
4726 if(zcmusic!=NULL)
4727 {
4728 zcmusic_poll();
4729 }
4730
4731 update_hw_screen();
4732 }
4733
4734
2/2
✓ Branch 0 taken 4109618 times.
✓ Branch 1 taken 22 times.
4109640 if(Quit)
4735 22 return;
4736
4737
3/4
✓ Branch 0 taken 4050293 times.
✓ Branch 1 taken 59325 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4050293 times.
4109618 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4738 4050293 game->change_time(1);
4739
4740 4109618 Advance=false;
4741
4742 4109618 updatescr(allowwavy);
4743
4744
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4109614 times.
4109618 if (replay_is_active())
4745 {
4746
2/2
✓ Branch 0 taken 1270459 times.
✓ Branch 1 taken 2839155 times.
4109614 if (replay_get_version() >= 3)
4747 2839155 replay_poll();
4748
4749 // Replay compatability.
4750
4/4
✓ Branch 0 taken 688962 times.
✓ Branch 1 taken 3420652 times.
✓ Branch 2 taken 588427 times.
✓ Branch 3 taken 100535 times.
4109614 if (replay_get_version() >= 6 && replay_get_version() < 8)
4751 100535 replay_peek_input();
4752 4109614 }
4753
4754 4109618 update_keys();
4755
4756 4109618 ++frame;
4757
4758
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4109614 times.
4109618 if (replay_is_replaying())
4759 4109614 replay_do_cheats();
4760 4109618 syskeys();
4761
4762 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4763 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4764 // approach here means it doesn't matter which call adds the cheat.
4765 4109618 cheats_execute_queued();
4766
4767
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4109614 times.
4109618 if (replay_is_replaying())
4768 4109614 replay_peek_quit();
4769
2/2
✓ Branch 0 taken 4109604 times.
✓ Branch 1 taken 14 times.
4109618 if (GameFlags & GAMEFLAG_TRYQUIT)
4770 14 replay_step_quit(0);
4771
2/2
✓ Branch 0 taken 1464 times.
✓ Branch 1 taken 4108154 times.
4109618 if(allowF6Script)
4772 {
4773 4108154 FFCore.runF6Engine();
4774 4108154 }
4775
2/2
✓ Branch 0 taken 4109495 times.
✓ Branch 1 taken 123 times.
4109618 if (Quit)
4776 123 replay_step_quit(Quit);
4777 // Someday... maybe install a Turbo button here?
4778 4109618 throttleFPS();
4779
4780 #ifdef _WIN32
4781
4782 if(use_dwm_flush)
4783 {
4784 do_DwmFlush();
4785 }
4786
4787 #endif
4788
4789 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4790
2/2
✓ Branch 0 taken 6444 times.
✓ Branch 1 taken 4103174 times.
4109618 if(sfxcleanup)
4791 4103174 sfx_cleanup();
4792 4109640 }
4793
4794 12 void zapout()
4795 {
4796 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4797 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4798
4799 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4800 12 script_drawing_commands.Clear();
4801
4802 // zap out
4803
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=1; i<=24; i++)
4804 {
4805 288 draw_fuzzy(i);
4806 288 syskeys();
4807 288 advanceframe(true);
4808
4809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4810 {
4811 break;
4812 }
4813 288 }
4814 12 }
4815
4816 12 void zapin()
4817 {
4818 12 FFCore.warpScriptCheck();
4819 12 draw_screen(tmpscr);
4820 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4821 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4822 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4823
4824 // zap out
4825 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4826
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=24; i>=1; i--)
4827 {
4828 288 draw_fuzzy(i);
4829 288 syskeys();
4830 288 advanceframe(true);
4831
4832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4833 {
4834 break;
4835 }
4836 288 }
4837 12 }
4838
4839
4840 5 void wavyout(bool showhero)
4841 {
4842 5 draw_screen(tmpscr, showhero);
4843 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4844
4845 5 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4846 5 clear_to_color(wavebuf,0);
4847 5 blit(framebuf,wavebuf,0,0,16,0,256,224);
4848
4849 static PALETTE wavepal;
4850
4851 int32_t ofs;
4852 5 int32_t amplitude=8;
4853
4854 5 int32_t wavelength=4;
4855 5 double palpos=0, palstep=4, palstop=126;
4856
4857 5 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4858
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 210 times.
215 for(int32_t i=0; i<168; i+=wavelength)
4859 {
4860
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t l=0; l<256; l++)
4861 {
4862 53760 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4863 53760 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4864 53760 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4865 53760 }
4866
4867 210 palpos+=palstep;
4868
4869
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(palpos>=0)
4870 {
4871 210 hw_palette = &wavepal;
4872 210 update_hw_pal = true;
4873 210 }
4874 else
4875 {
4876 hw_palette = &RAMpal;
4877 update_hw_pal = true;
4878 }
4879
4880
2/2
✓ Branch 0 taken 35280 times.
✓ Branch 1 taken 210 times.
35490 for(int32_t j=0; j+playing_field_offset<224; j++)
4881 {
4882
2/2
✓ Branch 0 taken 9031680 times.
✓ Branch 1 taken 35280 times.
9066960 for(int32_t k=0; k<256; k++)
4883 {
4884 9031680 ofs=0;
4885
4886
4/4
✓ Branch 0 taken 4408320 times.
✓ Branch 1 taken 4623360 times.
✓ Branch 2 taken 2204160 times.
✓ Branch 3 taken 2204160 times.
9031680 if((j<i)&&(j&1))
4887 {
4888 2204160 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4889 2204160 }
4890
4891 9031680 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4892 9031680 }
4893 35280 }
4894
4895 210 syskeys();
4896 210 advanceframe(true);
4897
4898 // animate_combos();
4899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(Quit)
4900 break;
4901 210 }
4902
4903 5 destroy_bitmap(wavebuf);
4904 5 }
4905
4906 5 void wavyin()
4907 {
4908 5 draw_screen(tmpscr);
4909 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4910
4911 5 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4912 5 clear_to_color(wavebuf,0);
4913 5 blit(framebuf,wavebuf,0,0,16,0,256,224);
4914
4915 static PALETTE wavepal;
4916
4917 //Breaks dark rooms.
4918 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4919 /*
4920 loadfullpal();
4921 loadlvlpal(DMaps[currdmap].color);
4922 ringcolor(false);
4923 */
4924 5 refreshpal=false;
4925 int32_t ofs;
4926 5 int32_t amplitude=8;
4927 5 int32_t wavelength=4;
4928 5 double palpos=168, palstep=4, palstop=126;
4929
4930 5 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4931
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 210 times.
215 for(int32_t i=0; i<168; i+=wavelength)
4932 {
4933
2/2
✓ Branch 0 taken 53760 times.
✓ Branch 1 taken 210 times.
53970 for(int32_t l=0; l<256; l++)
4934 {
4935 53760 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4936 53760 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4937 53760 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4938 53760 }
4939
4940 210 palpos-=palstep;
4941
4942
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 if(palpos>=0)
4943 {
4944 210 hw_palette = &wavepal;
4945 210 update_hw_pal = true;
4946 210 }
4947 else
4948 {
4949 hw_palette = &RAMpal;
4950 update_hw_pal = true;
4951 }
4952
4953
2/2
✓ Branch 0 taken 35280 times.
✓ Branch 1 taken 210 times.
35490 for(int32_t j=0; j+playing_field_offset<224; j++)
4954 {
4955
2/2
✓ Branch 0 taken 9031680 times.
✓ Branch 1 taken 35280 times.
9066960 for(int32_t k=0; k<256; k++)
4956 {
4957 9031680 ofs=0;
4958
4959
4/4
✓ Branch 0 taken 4569600 times.
✓ Branch 1 taken 4462080 times.
✓ Branch 2 taken 2311680 times.
✓ Branch 3 taken 2257920 times.
9031680 if((j<(167-i))&&(j&1))
4960 {
4961 2257920 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4962 2257920 }
4963
4964 9031680 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4965 9031680 }
4966 35280 }
4967
4968 210 syskeys();
4969 210 advanceframe(true);
4970 // animate_combos();
4971
4972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(Quit)
4973 break;
4974 210 }
4975
4976 5 destroy_bitmap(wavebuf);
4977 5 }
4978
4979 1207 void blackscr(int32_t fcnt,bool showsubscr)
4980 {
4981 1207 reset_pal_cycling();
4982 1207 script_drawing_commands.Clear();
4983
4984 1207 FFCore.warpScriptCheck();
4985 1207 bool showtime = game->should_show_time();
4986
2/2
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 36140 times.
37347 while(fcnt>0)
4987 {
4988 36140 clear_bitmap(framebuf);
4989
4990
2/2
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 26780 times.
36140 if(showsubscr)
4991 {
4992 26780 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4993
3/4
✓ Branch 0 taken 26780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 26030 times.
26780 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4994 {
4995 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4996 750 }
4997 26780 }
4998
4999 36140 syskeys();
5000 36140 advanceframe(true);
5001
5002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36140 times.
36140 if(Quit)
5003 break;
5004
5005 36140 --fcnt;
5006 }
5007 1207 }
5008
5009 291 void openscreen(int32_t shape)
5010 {
5011 291 reset_pal_cycling();
5012 291 black_opening_count=0;
5013
5014
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
291 if(COOLSCROLL || shape>-1)
5015 {
5016 193 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5017 193 return;
5018 }
5019 else
5020 {
5021 98 Hero.setDontDraw(true);
5022 98 show_subscreen_dmap_dots=false;
5023 98 show_subscreen_numbers=false;
5024 // show_subscreen_items=false;
5025 98 show_subscreen_life=false;
5026 }
5027
5028 98 int32_t x=128;
5029
5030 98 FFCore.warpScriptCheck();
5031
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5032 {
5033 7840 draw_screen(tmpscr);
5034 //? draw_screen already draws the subscreen -DD
5035 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5036 7840 x=128-(((i*128/80)/8)*8);
5037
5038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5039 {
5040 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5041 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5042 7840 }
5043
5044 // x=((80-i)/2)*4;
5045 /*
5046 --x;
5047 switch(++c)
5048 {
5049 case 5: c=0;
5050 case 0:
5051 case 2:
5052 case 3: --x; break;
5053 }
5054 */
5055 7840 syskeys();
5056 7840 advanceframe(true);
5057
5058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5059 {
5060 break;
5061 }
5062 7840 }
5063
5064 98 Hero.setDontDraw(false);
5065 98 show_subscreen_items=true;
5066 98 show_subscreen_dmap_dots=true;
5067 291 }
5068
5069 void closescreen(int32_t shape)
5070 {
5071 reset_pal_cycling();
5072 black_opening_count=0;
5073
5074 if(COOLSCROLL || shape>-1)
5075 {
5076 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5077 return;
5078 }
5079 else
5080 {
5081 Hero.setDontDraw(true);
5082 show_subscreen_dmap_dots=false;
5083 show_subscreen_numbers=false;
5084 // show_subscreen_items=false;
5085 show_subscreen_life=false;
5086 }
5087
5088 int32_t x=128;
5089
5090 FFCore.warpScriptCheck();
5091 for(int32_t i=79; i>=0; --i)
5092 {
5093 draw_screen(tmpscr);
5094 //? draw_screen already draws the subscreen -DD
5095 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5096 x=128-(((i*128/80)/8)*8);
5097
5098 if(x>0)
5099 {
5100 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5101 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5102 }
5103
5104 // x=((80-i)/2)*4;
5105 /*
5106 --x;
5107 switch(++c)
5108 {
5109 case 5: c=0;
5110 case 0:
5111 case 2:
5112 case 3: --x; break;
5113 }
5114 */
5115 syskeys();
5116 advanceframe(true);
5117
5118 if(Quit)
5119 {
5120 break;
5121 }
5122 }
5123
5124 Hero.setDontDraw(false);
5125 show_subscreen_items=true;
5126 show_subscreen_dmap_dots=true;
5127 }
5128
5129 84 int32_t TriforceCount()
5130 {
5131 84 int32_t c=0;
5132
5133
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
756 for(int32_t i=1; i<=8; i++)
5134
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 374 times.
1046 if(game->lvlitems[i]&liTRIFORCE)
5135 374 ++c;
5136
5137 84 return c;
5138 }
5139
5140 int32_t onCustomGame()
5141 {
5142 int32_t file = getsaveslot();
5143
5144 if(file < 0)
5145 return D_O_K;
5146
5147 bool ret = (custom_game(file)!=0);
5148 return ret ? D_CLOSE : D_O_K;
5149 }
5150
5151 int32_t onContinue()
5152 {
5153 return D_CLOSE;
5154 }
5155
5156 int32_t onEsc() // Unused?? -L
5157 {
5158 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5159 }
5160
5161 int32_t onVsync()
5162 {
5163 Throttlefps = !Throttlefps;
5164 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5165 return D_O_K;
5166 }
5167
5168 int32_t onWinPosSave()
5169 {
5170 SaveWinPos = !SaveWinPos;
5171 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5172 return D_O_K;
5173 }
5174
5175 int32_t onClickToFreeze()
5176 {
5177 ClickToFreeze = !ClickToFreeze;
5178 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5179 return D_O_K;
5180 }
5181
5182 int32_t OnSaveZCConfig()
5183 {
5184 if(jwin_alert3(
5185 "Save Configuration",
5186 "Are you sure that you wish to save your present configuration settings?",
5187 "This will overwrite your prior settings!",
5188 NULL,
5189 "&Yes",
5190 "&No",
5191 NULL,
5192 'y',
5193 'n',
5194 0,
5195 lfont) == 1)
5196 {
5197 save_game_configs();
5198 return D_O_K;
5199 }
5200 else return D_O_K;
5201 }
5202
5203 int32_t OnnClearQuestDir()
5204 {
5205 if(jwin_alert3(
5206 "Clear Current Directory Cache",
5207 "Are you sure that you wish to clear the current cached directory?",
5208 "This will default the current directory to the ROOT for this instance of ZC Player!",
5209 NULL,
5210 "&Yes",
5211 "&No",
5212 NULL,
5213 'y',
5214 'n',
5215 0,
5216 lfont) == 1)
5217 {
5218 zc_set_config("zeldadx","win_qst_dir","");
5219 flush_config_file();
5220 strcpy(qstdir,"");
5221 #ifdef __EMSCRIPTEN__
5222 em_sync_fs();
5223 #endif
5224 return D_O_K;
5225 }
5226 else return D_O_K;
5227 }
5228
5229
5230 int32_t onConsoleZASM()
5231 {
5232 if ( !zasm_debugger )
5233 {
5234 AlertDialog("WARNING: ZASM Debugger",
5235 "Enabling this will open the ZASM Debugger Console"
5236 "\nThis will likely grind ZC to a halt with lag."
5237 "\nTo make any use of this, it is suggested that you read"
5238 "\nthe documentation for 'void Breakpoint(char[] string);'"
5239 " in 'ZScript_Additions.txt'"
5240 "\nThis is not recommended for normal users,"
5241 " and is only intended for ZC developers,"
5242 "\nor quest developers coding directly in ZASM"
5243 "\nAre you sure that you wish to open the ZASM Debugger?",
5244 [&](bool ret,bool)
5245 {
5246 if(ret)
5247 {
5248 FFCore.ZASMPrint(true);
5249 }
5250 }).show();
5251 return D_O_K;
5252 }
5253 else
5254 {
5255 FFCore.ZASMPrint(false);
5256 return D_O_K;
5257 }
5258 }
5259
5260
5261 int32_t onConsoleZScript()
5262 {
5263 if ( !zscript_debugger )
5264 {
5265 AlertDialog("ZScript Debugger",
5266 "Enabling this will open the ZScript Debugger Console"
5267 "\nThis will display any messages logged by scripts,"
5268 " including script errors."
5269 "\nAre you sure that you wish to open the ZScript Debugger?",
5270 [&](bool ret,bool)
5271 {
5272 if(ret)
5273 {
5274 FFCore.ZScriptConsole(true);
5275 }
5276 }).show();
5277 return D_O_K;
5278 }
5279 else
5280 {
5281 FFCore.ZScriptConsole(false);
5282 return D_O_K;
5283 }
5284 }
5285
5286 int32_t onClrConsoleOnLoad()
5287 {
5288 clearConsoleOnLoad = !clearConsoleOnLoad;
5289 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5290 return D_O_K;
5291 }
5292
5293
5294 int32_t onFrameSkip()
5295 {
5296 FrameSkip = !FrameSkip;
5297 return D_O_K;
5298 }
5299
5300 int32_t onSaveDragResize()
5301 {
5302 SaveDragResize = !SaveDragResize;
5303 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5304 return D_O_K;
5305 }
5306
5307 int32_t onDragAspect()
5308 {
5309 DragAspect = !DragAspect;
5310 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5311 return D_O_K;
5312 }
5313
5314 int32_t onTransLayers()
5315 {
5316 TransLayers = !TransLayers;
5317 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5318 return D_O_K;
5319 }
5320
5321 int32_t onNESquit()
5322 {
5323 NESquit = !NESquit;
5324 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5325 return D_O_K;
5326 }
5327
5328 int32_t onVolKeys()
5329 {
5330 volkeys = !volkeys;
5331 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5332 return D_O_K;
5333 }
5334
5335 int32_t onShowFPS()
5336 {
5337 ShowFPS = !ShowFPS;
5338 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5339 return D_O_K;
5340 }
5341
5342 491744704 bool is_Fkey(int32_t k)
5343 {
5344
2/2
✓ Branch 0 taken 50007936 times.
✓ Branch 1 taken 441736768 times.
491744704 switch(k)
5345 {
5346 case KEY_F1:
5347 case KEY_F2:
5348 case KEY_F3:
5349 case KEY_F4:
5350 case KEY_F5:
5351 case KEY_F6:
5352 case KEY_F7:
5353 case KEY_F8:
5354 case KEY_F9:
5355 case KEY_F10:
5356 case KEY_F11:
5357 case KEY_F12:
5358 50007936 return true;
5359 }
5360
5361 441736768 return false;
5362 491744704 }
5363
5364 void kb_getkey(DIALOG *d)
5365 {
5366 d->flags|=D_SELECTED;
5367
5368 scare_mouse();
5369 jwin_button_proc(MSG_DRAW,d,0);
5370 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5371 // text_mode(vc(11));
5372 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5373 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5374 unscare_mouse();
5375
5376 update_hw_screen(true);
5377
5378 clear_keybuf();
5379 int32_t k = next_press_key();
5380 clear_keybuf();
5381
5382 //shnarf
5383 //47=f1
5384 //59=esc
5385 if(k>0 && k<123 && !((k>46)&&(k<60)))
5386 *((int32_t*)d->dp3) = k;
5387
5388
5389 d->flags&=~D_SELECTED;
5390 }
5391
5392
5393 //Used by all keyboard key settings dialogues.
5394 void kb_clearjoystick(DIALOG *d)
5395 {
5396 d->flags|=D_SELECTED;
5397
5398 scare_mouse();
5399 jwin_button_proc(MSG_DRAW,d,0);
5400 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5401 // text_mode(vc(11));
5402 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5403 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5404 unscare_mouse();
5405
5406 update_hw_screen(true);
5407
5408 clear_keybuf();
5409 int32_t k = next_press_key();
5410 clear_keybuf();
5411
5412 //shnarf
5413 //47=f1
5414 //59=esc
5415 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5416 // *((int32_t*)d->dp3) = k;
5417 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5418
5419
5420 d->flags&=~D_SELECTED;
5421 }
5422
5423 //Clears key to 0.
5424 //Used by all keyboard key settings dialogues.
5425 void kb_clearkey(DIALOG *d)
5426 {
5427 d->flags|=D_SELECTED;
5428
5429 scare_mouse();
5430 jwin_button_proc(MSG_DRAW,d,0);
5431 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5432 // text_mode(vc(11));
5433 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5434 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5435 unscare_mouse();
5436
5437 update_hw_screen(true);
5438
5439 clear_keybuf();
5440 int32_t k = next_press_key();
5441 clear_keybuf();
5442
5443 //shnarf
5444 //47=f1
5445 //59=esc
5446 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5447 // *((int32_t*)d->dp3) = k;
5448 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5449
5450
5451 d->flags&=~D_SELECTED;
5452 }
5453
5454
5455 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5456 {
5457 switch(msg)
5458 {
5459 case MSG_KEY:
5460 case MSG_CLICK:
5461
5462 kb_clearjoystick(d);
5463
5464 while(gui_mouse_b())
5465 {
5466 clear_keybuf();
5467 rest(1);
5468 }
5469
5470 return D_REDRAW;
5471 }
5472
5473 return jwin_button_proc(msg,d,c);
5474 }
5475
5476 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5477 {
5478 switch(msg)
5479 {
5480 case MSG_KEY:
5481 case MSG_CLICK:
5482
5483 kb_getkey(d);
5484
5485 while(gui_mouse_b()) {
5486 clear_keybuf();
5487 rest(1);
5488 }
5489
5490 return D_REDRAW;
5491 }
5492
5493 return jwin_button_proc(msg,d,c);
5494 }
5495
5496 //Only used in keyboard settings dialogues to clear keys.
5497 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5498 {
5499 switch(msg)
5500 {
5501 case MSG_KEY:
5502 case MSG_CLICK:
5503
5504 kb_clearkey(d);
5505
5506 while(gui_mouse_b()) {
5507 clear_keybuf();
5508 rest(1);
5509 }
5510
5511 return D_REDRAW;
5512 }
5513
5514 return jwin_button_proc(msg,d,c);
5515 }
5516
5517 void j_getbtn(DIALOG *d)
5518 {
5519 d->flags|=D_SELECTED;
5520 scare_mouse();
5521 jwin_button_proc(MSG_DRAW,d,0);
5522 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5523 // text_mode(vc(11));
5524 int32_t y = gui_bmp->h/2 - 12;
5525 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5526 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5527 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5528 unscare_mouse();
5529
5530 update_hw_screen(true);
5531
5532 int32_t b = next_press_btn();
5533
5534 if(b>=0)
5535 *((int32_t*)d->dp3) = b;
5536
5537 d->flags&=~D_SELECTED;
5538
5539 if (player)
5540 player->joy_on = TRUE;
5541 }
5542
5543 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5544 {
5545 switch(msg)
5546 {
5547 case MSG_KEY:
5548 case MSG_CLICK:
5549
5550 j_getbtn(d);
5551
5552 while(gui_mouse_b()) {
5553 rest(1);
5554 clear_keybuf();
5555 }
5556
5557 return D_REDRAW;
5558 }
5559
5560 return jwin_button_proc(msg,d,c);
5561 }
5562
5563 //shnarf
5564 const char *key_str[] =
5565 {
5566 "(none) ", "a ", "b ", "c ",
5567 "d ", "e ", "f ", "g ",
5568 "h ", "i ", "j ", "k ",
5569 "l ", "m ", "n ", "o ",
5570 "p ", "q ", "r ", "s ",
5571 "t ", "u ", "v ", "w ",
5572 "x ", "y ", "z ", "0 ",
5573 "1 ", "2 ", "3 ", "4 ",
5574 "5 ", "6 ", "7 ", "8 ",
5575 "9 ", "num 0 ", "num 1 ", "num 2 ",
5576 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5577 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5578 "f2 ", "f3 ", "f4 ", "f5 ",
5579 "f6 ", "f7 ", "f8 ", "f9 ",
5580 "f10 ", "f11 ", "f12 ", "esc ",
5581 "~ ", "- ", "= ", "backspace ",
5582 "tab ", "{ ", "} ", "enter ",
5583 ": ", "quote ", "\\ ", "\\ (2) ",
5584 ", ", ". ", "/ ", "space ",
5585 "insert ", "delete ", "home ", "end ",
5586 "page up ", "page down ", "left ", "right ",
5587 "up ", "down ", "num / ", "num * ",
5588 "num - ", "num + ", "num delete ", "num enter ",
5589 "print screen ", "pause ", "abnt c1 ", "yen ",
5590 "kana ", "convert ", "no convert ", "at ",
5591 "circumflex ", ": (2) ", "kanji ", "num = ",
5592 "back quote ", "; ", "command ", "unknown (0) ",
5593 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5594 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5595 "right shift ", "left control ", "right control", "alt ",
5596 "alt gr ", "left win ", "right win ", "menu ",
5597 "scroll lock ", "number lock ", "caps lock ", "MAX"
5598 };
5599
5600
5601 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5602 //extern int32_t zcmusic_bufsz;
5603
5604 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5605 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5606
5607 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5608 {
5609 //these are here to bypass compiler warnings about unused arguments
5610 c=c;
5611
5612 if(msg==MSG_DRAW)
5613 {
5614 switch(d->w)
5615 {
5616 case 0:
5617 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5618 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5619 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5620 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5621 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5622 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5623 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5624 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5625 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5626 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5627 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5628 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5629 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5630 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5631 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5632 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5633 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5634 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5635 break;
5636
5637 case 1:
5638 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5639 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5640 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5641 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5642 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5643 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5644 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5645 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5646 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5647 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5648 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5649 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5650 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5651 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5652 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5653 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5654 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5655 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5656 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5657 break;
5658
5659 case 2:
5660 sprintf(str_a," %3d",midi_volume);
5661 sprintf(str_b," %3d",digi_volume);
5662 sprintf(str_l," %3d",emusic_volume);
5663 sprintf(str_m," %3dKB",zcmusic_bufsz);
5664 sprintf(str_r," %3d",sfx_volume);
5665 strcpy(str_s,pan_str[pan_style]);
5666 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5667 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5668 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5669 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5670 break;
5671 }
5672 }
5673
5674 return D_O_K;
5675 }
5676
5677 int32_t set_vol(void *dp3, int32_t d2)
5678 {
5679 switch(((int32_t*)dp3)[0])
5680 {
5681 case 0:
5682 midi_volume = zc_min(d2<<3,255);
5683 break;
5684
5685 case 1:
5686 digi_volume = zc_min(d2<<3,255);
5687 break;
5688
5689 case 2:
5690 emusic_volume = zc_min(d2<<3,255);
5691 break;
5692
5693 case 3:
5694 sfx_volume = zc_min(d2<<3,255);
5695 break;
5696 }
5697
5698 scare_mouse();
5699 // text_mode(vc(11));
5700 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5701 unscare_mouse();
5702 return D_O_K;
5703 }
5704
5705 int32_t set_pan(void *dp3, int32_t d2)
5706 {
5707 pan_style = vbound(d2,0,3);
5708 scare_mouse();
5709 // text_mode(vc(11));
5710 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5711 unscare_mouse();
5712 return D_O_K;
5713 }
5714
5715 int32_t set_buf(void *dp3, int32_t d2)
5716 {
5717 scare_mouse();
5718 // text_mode(vc(11));
5719 zcmusic_bufsz = d2 + 1;
5720 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5721 unscare_mouse();
5722 return D_O_K;
5723 }
5724
5725 static int32_t gamepad_btn_list[] =
5726 {
5727 6,
5728 7,8,9,10,11,12,13,14,15,16,17,
5729 18,19,20,21,22,23,24,25,26,27,28,
5730 29,30,31,32,33,34,35,36,37,38,39,
5731 -1
5732 };
5733
5734 static int32_t gamepad_dirs_list[] =
5735 {
5736 40,41,42,43,
5737 44,45,46,47,
5738 48,49,50,51,
5739 52,53,54,55,
5740 56,
5741 -1
5742 };
5743
5744 static TABPANEL gamepad_tabs[] =
5745 {
5746 // (text)
5747 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5748 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5749 { NULL, 0, NULL, 0, NULL }
5750 };
5751
5752 static DIALOG gamepad_dlg[] =
5753 {
5754 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5755 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5756 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5757 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5758 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5759 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5760 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5761 // 6
5762 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5763 // 7
5764 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5765 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5766 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5767 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5768 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5769 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5770 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5771 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5772 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5773 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5774 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5775 // 18
5776 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5777 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5778 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5779 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5780 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5781 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5782 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5783 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5784 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5785 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5786 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5787 // 29
5788 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5789 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5790 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5791 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5792 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5793 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5794 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5795 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5796 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5797 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5798 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5799 // 40
5800 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5801 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5802 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5803 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5804 // 44
5805 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5806 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5807 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5808 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5809 // 48
5810 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5811 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5812 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5813 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5814 // 52
5815 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5816 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5817 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5818 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5819 // 56
5820 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5821 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5822 };
5823
5824 static int32_t keyboard_keys_list[] =
5825 {
5826 6,7,8,9,10,
5827 11,12,13,14,15,16,17,18,19,20,
5828 21,22,23,24,25,26,27,28,29,30,
5829 31,32,33,34,35,36,37,38,39,40,
5830 -1
5831 };
5832
5833 static int32_t keyboard_dirs_list[] =
5834 {
5835 41,42,43,44,
5836 45,46,47,48,
5837 49,50,51,52,
5838 53,54,55,56,
5839 -1
5840 };
5841
5842 static int32_t keyboard_mods_list[] =
5843 {
5844 57,58,59,60,
5845 61,62,63,64,
5846 65,66,67,68,
5847 69,70,71,72,
5848 -1
5849 };
5850
5851 static TABPANEL keyboard_control_tabs[] =
5852 {
5853 // (text)
5854 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5855 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5856 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5857 { NULL, 0, NULL, 0, NULL }
5858 };
5859
5860 static DIALOG keyboard_control_dlg[] =
5861 {
5862 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5863 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5864 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5865 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5866 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5867 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5868 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5869 // Keys
5870 // 6
5871 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5872 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5873 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5874 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5875 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5876 // 11
5877 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5878 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5879 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5880 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5881 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5882 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5883 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5884 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5885 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5886 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5887 // 21
5888 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5889 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5890 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5891 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5892 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5893 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5894 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5895 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5896 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5897 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5898 // 31
5899 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5900 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5901 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5902 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5903 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5904 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5905 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5906 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5907 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5908 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5909 // Dirs
5910 // 41
5911 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5912 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5913 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5914 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5915 // 45
5916 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5917 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5918 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5919 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5920 // 49
5921 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5922 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5923 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5924 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5925 // 53
5926 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5927 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5928 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5929 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5930 // Mods
5931 // 57
5932 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5933 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5934 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5935 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5936 // 61
5937 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5938 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5939 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5940 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5941 // 65
5942 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5943 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5944 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5945 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5946 // 69
5947 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5948 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5949 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5950 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5951 // 73
5952 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5953 };
5954
5955 /*
5956 int32_t midi_dp[3] = {0,147,104};
5957 int32_t digi_dp[3] = {1,147,120};
5958 int32_t pan_dp[3] = {0,147,136};
5959 int32_t buf_dp[3] = {0,147,152};
5960 */
5961 int32_t midi_dp[3] = {0,0,0};
5962 int32_t digi_dp[3] = {1,0,0};
5963 int32_t emus_dp[3] = {2,0,0};
5964 int32_t buf_dp[3] = {0,0,0};
5965 int32_t sfx_dp[3] = {3,0,0};
5966 int32_t pan_dp[3] = {0,0,0};
5967
5968 static DIALOG sound_dlg[] =
5969 {
5970 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5971 15 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5972 15 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5973 15 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5974 15 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5975 15 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5976 15 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5977 15 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5978 15 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5979 15 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5980 15 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5981 // 10
5982 15 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5983 15 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5984 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5985 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5986 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5987 15 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5988 15 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5989 15 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5990 15 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5991 15 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5992 //20
5993 15 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5994 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5995 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5996 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5997 15 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5998 15 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5999 15 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6000 15 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6001 15 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6002 15 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6003 //30
6004 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6005 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6006 15 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6007 15 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6008 };
6009
6010 char zc_builddate[80];
6011 char zc_aboutstr[80];
6012
6013 static DIALOG about_dlg[] =
6014 {
6015 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6016 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6017 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6018 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6019 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6020 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6021 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6022 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6023 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6024 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6025 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6026 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6027 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6028 };
6029
6030
6031 static DIALOG quest_dlg[] =
6032 {
6033 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6034 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6035 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6036 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6037 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6038 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6039 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6040 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6041 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6042 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6043 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6044 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6045 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6046 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6047 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6048 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6049 };
6050
6051 static DIALOG triforce_dlg[] =
6052 {
6053 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6054 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6055 // 1
6056 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6057 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6058 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6059 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6060 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6061 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6062 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6063 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6064 // 9
6065 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6066 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6067 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6068 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6069 };
6070
6071 /*static DIALOG equip_dlg[] =
6072 {
6073 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6074 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6075 // 1
6076 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6077 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6078 // 3
6079 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6080 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6081 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6082 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6083 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6084 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6085 // 9
6086 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6087 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6088 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6089 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6090 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6091 // 14
6092 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6093 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6094 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6095 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6096 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6097 // 19
6098 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6099 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6100 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6101 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6102 // 23
6103 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6104 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6105 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6106 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6107 // 27
6108 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6109 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6110 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6111 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6112 // 31
6113 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6114 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6115 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6116 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6117 // 35
6118 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6119 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6120 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6121 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6122 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6123 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6124 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6125 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6126 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6127 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6128 };
6129
6130 static DIALOG items_dlg[] =
6131 {
6132 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6133 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6134 //1
6135 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6136 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6137 // 3
6138 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6139 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6140 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6141 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6142 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6143 // 8
6144 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6145 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6146 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6147 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6148 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6149 // 13
6150 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6151 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6152 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6153 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6154 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6155 // 18
6156 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6157 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6158 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6159 // 21
6160 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6161 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6162 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6163 // 24
6164 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6165 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6166 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6167 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6168 // 28
6169 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6170 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6171 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6172 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6173 // 32
6174 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6175 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6176 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6177 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6178 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6179 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6180 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6181 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6182 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6183 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6184 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6185 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6186 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6187 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6188 //45
6189 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6190 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6191 };*/
6192
6193
6194
6195 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6196 {
6197 go();
6198 int32_t ret=0;
6199 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6200 comeback();
6201 return ret != 0;
6202 }
6203
6204
6205 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6206 {
6207 if(def!=modulepath)
6208 strcpy(modulepath,def);
6209
6210 if(!usefilename)
6211 {
6212 int32_t i=(int32_t)strlen(modulepath);
6213
6214 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6215 modulepath[i--]=0;
6216 }
6217
6218 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6219 int32_t ret=0;
6220 int32_t sel=0;
6221
6222 if(list==NULL)
6223 {
6224 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6225 }
6226 else
6227 {
6228 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6229 }
6230
6231 return ret!=0;
6232 }
6233
6234 //The Dialogue that loads a ZMOD Module File
6235 int32_t zc_load_zmod_module_file()
6236 {
6237 if ( Playing )
6238 {
6239 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6240 return -1;
6241 }
6242 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6243 return D_CLOSE;
6244
6245 FILE *tempmodule = fopen(modulepath,"r");
6246
6247 if(tempmodule == NULL)
6248 {
6249 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6250 return -1;
6251 }
6252
6253
6254 //Set the module path:
6255 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6256 strcpy(moduledata.module_name, modulepath);
6257 al_trace("New Module Path is: %s \n", moduledata.module_name);
6258 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6259 zcm.init(true); //Load the module values.
6260 moduledata.refresh_title_screen = 1;
6261 // refresh_select_screen = 1;
6262 build_biic_list();
6263 return D_O_K;
6264 }
6265
6266 static DIALOG module_info_dlg[] =
6267 {
6268 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6269
6270
6271 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6272 //1
6273 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6274 //2
6275 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6276 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6277 //4
6278 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6279 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6280 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6281 //7
6282
6283 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6284 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6285 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6286 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6287 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6288 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6289 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6290 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6291 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6292
6293 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6294 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6295 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6296 };
6297
6298 void about_zcplayer_module(const char *prompt,int32_t initialval)
6299 {
6300
6301 module_info_dlg[0].dp2 = lfont;
6302 if ( moduledata.moduletitle[0] != 0 )
6303 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6304
6305 if ( moduledata.moduleauthor[0] != 0 )
6306 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6307
6308 if ( moduledata.moduleinfo0[0] != 0 )
6309 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6310 if ( moduledata.moduleinfo1[0] != 0 )
6311 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6312 if ( moduledata.moduleinfo2[0] != 0 )
6313 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6314 if ( moduledata.moduleinfo3[0] != 0 )
6315 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6316 if ( moduledata.moduleinfo4[0] != 0 )
6317 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6318
6319 char module_date[255];
6320 memset(module_date, 0, sizeof(module_date));
6321 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6322 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6323
6324
6325
6326 char module_vers[255];
6327 memset(module_vers, 0, sizeof(module_vers));
6328 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6329
6330
6331 //sprintf(tilecount,"%d",1);
6332
6333 char module_build[255];
6334 memset(module_build, 0, sizeof(module_build));
6335 if ( moduledata.modbeta )
6336 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6337 else
6338 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6339
6340 module_info_dlg[12].dp = (char*)module_date;
6341 module_info_dlg[13].dp = (char*)module_vers;
6342 module_info_dlg[14].dp = (char*)module_build;
6343
6344 if(is_large)
6345 large_dialog(module_info_dlg);
6346
6347 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6348 jwin_center_dialog(module_info_dlg);
6349
6350
6351 }
6352
6353 int32_t onAbout_ZCP_Module()
6354 {
6355 about_zcplayer_module("About Module (.zmod)", 0);
6356 return D_O_K;
6357 }
6358
6359 //New Modules Menu for 2.55+
6360 static MENU zcmodule_menu[] =
6361 {
6362 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6363 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6364
6365 { NULL, NULL, NULL, 0, NULL }
6366 };
6367
6368 int32_t onToggleRecordingNewSaves()
6369 {
6370 if (zc_get_config("zeldadx", "replay_new_saves", false))
6371 {
6372 zc_set_config("zeldadx", "replay_new_saves", false);
6373 }
6374 else
6375 {
6376 zc_set_config("zeldadx", "replay_new_saves", true);
6377 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6378 NULL,NULL,"OK",NULL,13,27,lfont);
6379 }
6380 return D_O_K;
6381 }
6382
6383 int32_t onToggleSnapshotAllFrames()
6384 {
6385 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6386 return D_O_K;
6387 }
6388
6389 int32_t onStopReplayOrRecord()
6390 {
6391 if (replay_is_replaying())
6392 {
6393 replay_quit();
6394 }
6395 else if (replay_get_mode() == ReplayMode::Record)
6396 {
6397 if (!replay_get_meta_bool("test_mode"))
6398 {
6399 jwin_alert("Recording", "You cannot stop recording a save file.",
6400 NULL,NULL,"OK",NULL,13,27,lfont);
6401 return D_CLOSE;
6402 }
6403
6404 if (jwin_alert("Stop Recording",
6405 "Save replay to disk and stop recording?",
6406 "This will stop the recording.",
6407 NULL,
6408 "Yes","No",13,27,lfont) != 1)
6409 return D_CLOSE;
6410
6411 replay_save();
6412 replay_stop();
6413 }
6414 return D_O_K;
6415 }
6416
6417 static int32_t handle_on_load_replay(ReplayMode mode)
6418 {
6419 if (Playing)
6420 {
6421 if (jwin_alert("Replay - Warning!",
6422 "Loading a replay will exit the current game.",
6423 "All unsaved progress will be lost.",
6424 "Do you wish to continue?",
6425 "Yes","No",13,27,lfont) != 1)
6426 return D_CLOSE;
6427 }
6428
6429 std::string mode_string = replay_mode_to_string(mode);
6430 mode_string[0] = std::toupper(mode_string[0]);
6431
6432 std::string line_1 = "Select a replay file to play back.";
6433 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6434 std::string line_3 = "You can stop the replay and take over manually any time.";
6435 if (mode == ReplayMode::Update)
6436 {
6437 line_1 = "Select a replay file to update.";
6438 line_2 = "WARNING: be sure to back up the zplay file";
6439 line_3 = "and verify that the updated replay works as expected!";
6440 }
6441
6442 if (jwin_alert(mode_string.c_str(),
6443 line_1.c_str(),
6444 line_2.c_str(),
6445 line_3.c_str(),
6446 "OK","Nevermind",13,27,lfont) == 1)
6447 {
6448 char replay_path[2048];
6449 strcpy(replay_path, "replays/");
6450 if (jwin_file_select_ex(
6451 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6452 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6453 return D_CLOSE;
6454
6455 replay_quit();
6456 load_replay_file_deferred(mode, replay_path);
6457 Quit = qRESET;
6458 return D_CLOSE;
6459 }
6460 return D_O_K;
6461 }
6462
6463 int32_t onLoadReplay()
6464 {
6465 return handle_on_load_replay(ReplayMode::Replay);
6466 }
6467
6468 int32_t onLoadReplayAssert()
6469 {
6470 return handle_on_load_replay(ReplayMode::Assert);
6471 }
6472
6473 int32_t onLoadReplayUpdate()
6474 {
6475 return handle_on_load_replay(ReplayMode::Update);
6476 }
6477
6478 int32_t onSaveReplay()
6479 {
6480 if (replay_get_mode() == ReplayMode::Record)
6481 {
6482 if (!replay_get_meta_bool("test_mode"))
6483 {
6484 if (jwin_alert("Save Replay",
6485 "This will save a copy of the replay up to this point.",
6486 "The official replay file will be untouched.",
6487 "Do you wish to continue?",
6488 "Yes","No",13,27,lfont) != 1)
6489 return D_CLOSE;
6490
6491 char replay_path[2048];
6492 strcpy(replay_path, replay_get_replay_path().string().c_str());
6493 if (jwin_file_select_ex(
6494 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6495 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6496 return D_CLOSE;
6497
6498 if (fileexists(replay_path))
6499 {
6500 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6501 NULL,NULL,"OK",NULL,13,27,lfont);
6502 return D_CLOSE;
6503 }
6504
6505 replay_save(replay_path);
6506 }
6507 else
6508 {
6509 replay_save();
6510 }
6511 }
6512 return D_O_K;
6513 }
6514
6515 static MENU replay_menu[] =
6516 {
6517 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6518 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6519 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6520 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6521 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6522 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6523 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6524
6525 { NULL, NULL, NULL, 0, NULL }
6526 };
6527
6528 static DIALOG credits_dlg[] =
6529 {
6530 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6531 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6532 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6533 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6534 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6535 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6536 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6537 };
6538
6539 15 static ListData dmap_list(dmaplist, &font);
6540
6541 static DIALOG goto_dlg[] =
6542 {
6543 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6544 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6545 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6546 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6547 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6548 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6549 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6550 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6551 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6552 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6553 };
6554
6555 int32_t onGoTo()
6556 {
6557 bool music = false;
6558 music = music;
6559 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6560
6561 goto_dlg[0].dp2=lfont;
6562 goto_dlg[4].d2=cheat_goto_dmap;
6563 goto_dlg[6].dp=cheat_goto_screen_str;
6564
6565 clear_keybuf();
6566
6567 if(is_large)
6568 large_dialog(goto_dlg);
6569
6570 if(zc_popup_dialog(goto_dlg,4)==1)
6571 {
6572 // dmap, screen
6573 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6574 };
6575
6576 return D_O_K;
6577 }
6578
6579 int32_t onGoToComplete()
6580 {
6581 if(!Playing)
6582 {
6583 return D_O_K;
6584 }
6585
6586 system_pal();
6587 music_pause();
6588 pause_all_sfx();
6589 show_mouse(screen);
6590 onGoTo();
6591 eat_buttons();
6592
6593 zc_readrawkey(KEY_ESC);
6594
6595 show_mouse(NULL);
6596 game_pal();
6597 music_resume();
6598 resume_all_sfx();
6599 return D_O_K;
6600 }
6601
6602 int32_t onCredits()
6603 {
6604 go();
6605
6606 BITMAP *win = create_bitmap_ex(8,222,110);
6607
6608 if(!win)
6609 return D_O_K;
6610
6611 int32_t c=0;
6612 int32_t l=0;
6613 int32_t ol=-1;
6614 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6615 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6616 PALETTE tmppal;
6617
6618 rti_gui.transparency_index = 1;
6619
6620 clear_to_color(win, rti_gui.transparency_index);
6621 draw_rle_sprite(win,rle,0,0);
6622 credits_dlg[0].dp2=lfont;
6623 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6624 credits_dlg[2].dp = win;
6625
6626 set_palette_range(black_palette,0,127,false);
6627
6628 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6629
6630 BITMAP* old_screen = screen;
6631 BITMAP* gui_bmp = zc_get_gui_bmp();
6632 ASSERT(gui_bmp);
6633 clear_to_color(gui_bmp, rti_gui.transparency_index);
6634 screen = gui_bmp;
6635
6636 while(update_dialog(p))
6637 {
6638 throttleFPS();
6639 ++c;
6640 l = zc_max((c>>1)-30,0);
6641
6642 if(l > rle->h)
6643 l = c = 0;
6644
6645 if(l > rle->h - 112)
6646 l = rle->h - 112;
6647
6648 clear_bitmap(win);
6649 draw_rle_sprite(win,rle,0,0-l);
6650
6651 if(c<=64)
6652 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6653
6654 set_palette_range(tmppal,0,127,false);
6655
6656 if(l!=ol)
6657 {
6658 scare_mouse();
6659 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6660 unscare_mouse();
6661 SCRFIX();
6662 ol=l;
6663 }
6664
6665 update_hw_screen();
6666 }
6667
6668 screen = old_screen;
6669 system_pal();
6670
6671 shutdown_dialog(p);
6672 destroy_bitmap(win);
6673 //comeback();
6674
6675 rti_gui.transparency_index = 0;
6676
6677 return D_O_K;
6678 }
6679
6680 const char *midilist(int32_t index, int32_t *list_size)
6681 {
6682 if(index<0)
6683 {
6684 *list_size=0;
6685
6686 for(int32_t i=0; i<MAXMIDIS; i++)
6687 if(tunes[i].data)
6688 ++(*list_size);
6689
6690 return NULL;
6691 }
6692
6693 int32_t i=0,m=0;
6694
6695 while(m<=index && i<=MAXMIDIS)
6696 {
6697 if(tunes[i].data)
6698 ++m;
6699
6700 ++i;
6701 }
6702
6703 --i;
6704
6705 if(i==MAXMIDIS && m<index)
6706 return "(null)";
6707
6708 return tunes[i].title;
6709 }
6710
6711 /* ------- MIDI info stuff -------- */
6712
6713 char *text;
6714 midi_info *zmi;
6715 bool dialog_running;
6716 bool listening;
6717
6718 void get_info(int32_t index);
6719
6720 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6721 {
6722 int32_t d2 = d->d2;
6723 int32_t ret = jwin_droplist_proc(msg,d,c);
6724
6725 if(d2!=d->d2)
6726 {
6727 get_info(d->d2);
6728 }
6729
6730 return ret;
6731 }
6732
6733 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6734 {
6735 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6736
6737 int32_t ret = jwin_button_proc(msg,d,c);
6738
6739 if(ret == D_CLOSE)
6740 {
6741 // get current midi index
6742 int32_t index = (d+(d->d1))->d2;
6743 int32_t i=0, m=0;
6744
6745 while(m<=index && i<=MAXMIDIS)
6746 {
6747 if(tunes[i].data)
6748 ++m;
6749
6750 ++i;
6751 }
6752
6753 --i;
6754 jukebox(i);
6755 listening = true;
6756 ret = D_O_K;
6757 }
6758
6759 return ret;
6760 }
6761
6762 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6763 {
6764 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6765
6766 int32_t ret = jwin_button_proc(msg,d,c);
6767
6768 if(ret == D_CLOSE)
6769 {
6770 // get current midi index
6771 int32_t index = (d+(d->d1))->d2;
6772 int32_t i=0, m=0;
6773
6774 while(m<=index && i<=MAXMIDIS)
6775 {
6776 if(tunes[i].data)
6777 ++m;
6778
6779 ++i;
6780 }
6781
6782 --i;
6783
6784 // get file name
6785
6786 int32_t sel=0;
6787 //struct ffblk f;
6788 char title[40] = "Save MIDI: ";
6789 char fname[2048];
6790 memset(fname,0,2048);
6791 static EXT_LIST list[] =
6792 {
6793 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6794 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6795 { NULL, NULL }
6796 };
6797
6798 strcpy(title+11, tunes[i].title);
6799 title[39] = '\0';
6800
6801 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6802 goto done;
6803
6804 if(exists(fname))
6805 {
6806 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6807 goto done;
6808 }
6809
6810 // save midi i
6811
6812 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6813 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6814
6815 done:
6816 chop_path(fname);
6817 ret = D_REDRAW;
6818 }
6819
6820 return ret;
6821 }
6822
6823 15 static ListData midi_list(midilist, &font);
6824
6825 static DIALOG midi_dlg[] =
6826 {
6827 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6828 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6829 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6830 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6831 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6832 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6833 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6834 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6835 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6836 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6837 };
6838
6839 void get_info(int32_t index)
6840 {
6841 int32_t i=0, m=0;
6842
6843 while(m<=index && i<=MAXMIDIS)
6844 {
6845 if(tunes[i].data)
6846 ++m;
6847
6848 ++i;
6849 }
6850
6851 --i;
6852
6853 if(i==MAXMIDIS && m<index)
6854 strcpy(text,"(null)");
6855 else
6856 {
6857 get_midi_info((MIDI*)tunes[i].data,zmi);
6858 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6859 }
6860
6861 midi_dlg[0].dp2=lfont;
6862 midi_dlg[3].dp = text;
6863 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6864 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6865
6866 if(dialog_running)
6867 {
6868 scare_mouse();
6869 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6870 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6871 unscare_mouse();
6872 }
6873 }
6874
6875 int32_t onMIDICredits()
6876 {
6877 text = (char*)malloc(4096);
6878 zmi = (midi_info*)malloc(sizeof(midi_info));
6879
6880 if(!text || !zmi)
6881 {
6882 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6883 return D_O_K;
6884 }
6885
6886 bool do_pause_midi = midi_pos >= 0 && currmidi;
6887 auto restore_midi = currmidi;
6888 if(do_pause_midi)
6889 {
6890 paused_midi_pos = midi_pos;
6891 stop_midi();
6892 midi_paused=true;
6893 midi_suspended = midissuspHALTED;
6894 }
6895
6896 midi_dlg[0].dp2=lfont;
6897 midi_dlg[2].d1 = 0;
6898 midi_dlg[2].d2 = 0;
6899 midi_dlg[4].flags = D_EXIT;
6900 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6901
6902 listening = false;
6903 dialog_running=false;
6904 get_info(0);
6905
6906 dialog_running=true;
6907
6908 if(is_large)
6909 large_dialog(midi_dlg);
6910
6911 zc_popup_dialog(midi_dlg,0);
6912 dialog_running=false;
6913
6914 if(listening)
6915 music_stop();
6916
6917 if(do_pause_midi)
6918 {
6919 midi_suspended = midissuspRESUME;
6920 currmidi = restore_midi;
6921 midi_pos = paused_midi_pos;
6922 }
6923
6924 if(text) free(text);
6925 if(zmi) free(zmi);
6926 return D_O_K;
6927 }
6928
6929 int32_t onAbout()
6930 {
6931 char buf1[80]={0};
6932 std::ostringstream oss;
6933 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6934 oss << buf1 << '\n';
6935 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6936 oss << buf1 << '\n';
6937 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6938 oss << buf1 << '\n';
6939 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6940 oss << buf1 << '\n';
6941 sprintf(buf1, "Tag: %s", getReleaseTag());
6942 oss << buf1 << '\n';
6943
6944 InfoDialog("About ZC", oss.str()).show();
6945 return D_O_K;
6946 }
6947
6948 int32_t onQuest()
6949 {
6950 char fname[100];
6951 strcpy(fname, get_filename(qstpath));
6952 quest_dlg[0].dp2=lfont;
6953 quest_dlg[1].dp = fname;
6954
6955 if(QHeader.quest_number==0)
6956 sprintf(str_a,"Custom");
6957 else
6958 sprintf(str_a,"%d",QHeader.quest_number);
6959
6960 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6961
6962 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6963 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6964
6965 if(is_large)
6966 large_dialog(quest_dlg);
6967
6968 zc_popup_dialog(quest_dlg, 0);
6969 return D_O_K;
6970 }
6971
6972 void call_vidmode_dlg();
6973 int32_t onVidMode()
6974 {
6975 call_vidmode_dlg();
6976 return D_O_K;
6977 }
6978
6979 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6980 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6981 //Added an extra statement, so that if the key is cleared to 0, the cleared
6982 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6983
6984 void load_ukeys(int32_t* arr)
6985 {
6986 arr[ukey_a] = Akey;
6987 arr[ukey_b] = Bkey;
6988 arr[ukey_s] = Skey;
6989 arr[ukey_l] = Lkey;
6990 arr[ukey_r] = Rkey;
6991 arr[ukey_p] = Pkey;
6992 arr[ukey_ex1] = Exkey1;
6993 arr[ukey_ex2] = Exkey2;
6994 arr[ukey_ex3] = Exkey3;
6995 arr[ukey_ex4] = Exkey4;
6996 arr[ukey_du] = DUkey;
6997 arr[ukey_dd] = DDkey;
6998 arr[ukey_dl] = DLkey;
6999 arr[ukey_dr] = DRkey;
7000 arr[ukey_mod1a] = cheat_modifier_keys[0];
7001 arr[ukey_mod1b] = cheat_modifier_keys[1];
7002 arr[ukey_mod2a] = cheat_modifier_keys[2];
7003 arr[ukey_mod2b] = cheat_modifier_keys[3];
7004 };
7005
7006 static const char* ukey_names[] = {
7007 "A", "B", "Start", "L", "R", "Map",
7008 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7009 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7010 "Cheat Mod R1", "Cheat Mod R2",
7011 };
7012 std::string get_ukey_name(int32_t k)
7013 {
7014 if (k < num_ukey) return ukey_names[k];
7015 return "";
7016 }
7017
7018 int32_t onKeyboard()
7019 {
7020 int32_t a = Akey;
7021 int32_t b = Bkey;
7022 int32_t s = Skey;
7023 int32_t l = Lkey;
7024 int32_t r = Rkey;
7025 int32_t p = Pkey;
7026 int32_t ex1 = Exkey1;
7027 int32_t ex2 = Exkey2;
7028 int32_t ex3 = Exkey3;
7029 int32_t ex4 = Exkey4;
7030 int32_t du = DUkey;
7031 int32_t dd = DDkey;
7032 int32_t dl = DLkey;
7033 int32_t dr = DRkey;
7034 int32_t mod1a = cheat_modifier_keys[0];
7035 int32_t mod1b = cheat_modifier_keys[1];
7036 int32_t mod2a = cheat_modifier_keys[2];
7037 int32_t mod2b = cheat_modifier_keys[3];
7038 bool done=false;
7039 int32_t ret;
7040
7041 keyboard_control_dlg[0].dp2=lfont;
7042
7043 if(is_large)
7044 large_dialog(keyboard_control_dlg);
7045
7046 while(!done)
7047 {
7048 ret = zc_popup_dialog(keyboard_control_dlg,3);
7049
7050 if(ret==3) // OK
7051 {
7052 int32_t ukeys[num_ukey];
7053 load_ukeys(ukeys);
7054 std::vector<std::string> uniqueError;
7055 for(int32_t q = 0; q < num_ukey; ++q)
7056 {
7057 for(int32_t p = q+1; p < num_ukey; ++p)
7058 {
7059 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7060 {
7061 char buf[64];
7062 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7063 std::string str(buf);
7064 uniqueError.push_back(str);
7065 }
7066 }
7067 }
7068 if(uniqueError.size() == 0)
7069 {
7070 done = true;
7071 save_control_configs(true);
7072 }
7073 else
7074 {
7075 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7076 box_out("Cannot have duplicate keybinds!"); box_eol();
7077 for(std::vector<std::string>::iterator it = uniqueError.begin();
7078 it != uniqueError.end(); ++it)
7079 {
7080 box_out((*it).c_str()); box_eol();
7081 }
7082 box_end(true);
7083 }
7084 /* Old uniqueness check
7085 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7086 bool unique = true;
7087 addToHash(A,unique,keyhash);
7088 addToHash(B,unique,keyhash);
7089 addToHash(S,unique,keyhash);
7090 addToHash(L,unique,keyhash);
7091 addToHash(R,unique,keyhash);
7092 addToHash(P,unique,keyhash);
7093 addToHash(DU,unique,keyhash);
7094 addToHash(DD,unique,keyhash);
7095 addToHash(DL,unique,keyhash);
7096 addToHash(DR,unique,keyhash);
7097
7098 if(keyhash->find(Exkey1) == keyhash->end())
7099 {
7100 (*keyhash)[Exkey1]=true;
7101 }
7102 else
7103 {
7104 if ( Exkey1 != 0 ) unique = false;
7105 }
7106
7107 if(keyhash->find(Exkey2) == keyhash->end())
7108 {
7109 (*keyhash)[Exkey2]=true;
7110 }
7111 else
7112 {
7113 if ( Exkey2 != 0 ) unique = false;
7114 }
7115
7116 if(keyhash->find(Exkey3) == keyhash->end())
7117 {
7118 (*keyhash)[Exkey3]=true;
7119 }
7120 else
7121 {
7122 if ( Exkey3 != 0 ) unique = false;
7123 }
7124
7125 if(keyhash->find(Exkey4) == keyhash->end())
7126 {
7127 (*keyhash)[Exkey4]=true;
7128 }
7129 else
7130 {
7131 if ( Exkey4 != 0 )unique = false;
7132 }
7133 //modifier keys
7134 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7135 {
7136 (*keyhash)[cheat_modifier_keys[0]]=true;
7137 }
7138 else
7139 {
7140 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7141 }
7142 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7143 {
7144 (*keyhash)[cheat_modifier_keys[1]]=true;
7145 }
7146 else
7147 {
7148 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7149 }
7150 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7151 {
7152 (*keyhash)[cheat_modifier_keys[2]]=true;
7153 }
7154 else
7155 {
7156 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7157 }
7158 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7159 {
7160 (*keyhash)[cheat_modifier_keys[3]]=true;
7161 }
7162 else
7163 {
7164 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7165 }
7166
7167 delete keyhash;
7168
7169 if(unique)
7170 done=true;
7171 else
7172 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7173 */
7174 }
7175 else // Cancel
7176 {
7177 Akey = a;
7178 Bkey = b;
7179 Skey = s;
7180 Lkey = l;
7181 Rkey = r;
7182 Pkey = p;
7183 Exkey1 = ex1;
7184 Exkey2 = ex2;
7185 Exkey3 = ex3;
7186 Exkey4 = ex4;
7187 DUkey = du;
7188 DDkey = dd;
7189 DLkey = dl;
7190 DRkey = dr;
7191 cheat_modifier_keys[0] = mod1a;
7192 cheat_modifier_keys[1] = mod1b;
7193 cheat_modifier_keys[2] = mod2a;
7194 cheat_modifier_keys[3] = mod2b;
7195
7196 done=true;
7197 }
7198
7199 rest(1);
7200 }
7201
7202 return D_O_K;
7203 }
7204
7205 int32_t onGamepad()
7206 {
7207 int32_t a = Abtn;
7208 int32_t b = Bbtn;
7209 int32_t s = Sbtn;
7210 int32_t l = Lbtn;
7211 int32_t r = Rbtn;
7212 int32_t m = Mbtn;
7213 int32_t p = Pbtn;
7214 int32_t ex1 = Exbtn1;
7215 int32_t ex2 = Exbtn2;
7216 int32_t ex3 = Exbtn3;
7217 int32_t ex4 = Exbtn4;
7218 int32_t up = DUbtn;
7219 int32_t down = DDbtn;
7220 int32_t left = DLbtn;
7221 int32_t right = DRbtn;
7222
7223 gamepad_dlg[0].dp2=lfont;
7224 if(analog_movement)
7225 gamepad_dlg[56].flags|=D_SELECTED;
7226 else
7227 gamepad_dlg[56].flags&=~D_SELECTED;
7228
7229 if(is_large)
7230 large_dialog(gamepad_dlg);
7231
7232 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7233
7234 if(ret == 4) //OK
7235 {
7236 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7237 save_control_configs(false);
7238 }
7239 else //Cancel
7240 {
7241 Abtn = a;
7242 Bbtn = b;
7243 Sbtn = s;
7244 Lbtn = l;
7245 Rbtn = r;
7246 Mbtn = m;
7247 Pbtn = p;
7248 Exbtn1 = ex1;
7249 Exbtn2 = ex2;
7250 Exbtn3 = ex3;
7251 Exbtn4 = ex4;
7252 DUbtn = up;
7253 DDbtn = down;
7254 DLbtn = left;
7255 DRbtn = right;
7256 }
7257
7258 return D_O_K;
7259 }
7260
7261 int32_t onSound()
7262 {
7263 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7264 {
7265 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7266 }
7267 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7268 {
7269 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7270 }
7271 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7272 {
7273 emusic_volume = (int32_t)FFCore.usr_music_volume;
7274 }
7275 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7276 {
7277 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7278 }
7279 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7280 {
7281 pan_style = (int32_t)FFCore.usr_panstyle;
7282 }
7283
7284 int32_t m = midi_volume;
7285 int32_t d = digi_volume;
7286 int32_t e = emusic_volume;
7287 int32_t b = zcmusic_bufsz;
7288 int32_t s = sfx_volume;
7289 int32_t p = pan_style;
7290 pan_style = vbound(pan_style,0,3);
7291
7292 sound_dlg[0].dp2=lfont;
7293
7294 if(is_large)
7295 large_dialog(sound_dlg);
7296
7297 midi_dp[1] = sound_dlg[6].x;
7298 midi_dp[2] = sound_dlg[6].y;
7299 digi_dp[1] = sound_dlg[7].x;
7300 digi_dp[2] = sound_dlg[7].y;
7301 emus_dp[1] = sound_dlg[8].x;
7302 emus_dp[2] = sound_dlg[8].y;
7303 buf_dp[1] = sound_dlg[9].x;
7304 buf_dp[2] = sound_dlg[9].y;
7305 sfx_dp[1] = sound_dlg[10].x;
7306 sfx_dp[2] = sound_dlg[10].y;
7307 pan_dp[1] = sound_dlg[11].x;
7308 pan_dp[2] = sound_dlg[11].y;
7309 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7310 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7311 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7312 sound_dlg[18].d2 = zcmusic_bufsz;
7313 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7314 sound_dlg[20].d2 = pan_style;
7315
7316 int32_t ret = zc_popup_dialog(sound_dlg,1);
7317
7318 if(ret==2)
7319 {
7320 master_volume(digi_volume,midi_volume);
7321
7322 for(int32_t i=0; i<WAV_COUNT; ++i)
7323 {
7324 //allegro assertion fails when passing in -1 as voice -DD
7325 if(sfx_voice[i] > 0)
7326 voice_set_volume(sfx_voice[i], sfx_volume);
7327 }
7328 zc_set_config(sfx_sect,"digi",digi_volume);
7329 zc_set_config(sfx_sect,"midi",midi_volume);
7330 zc_set_config(sfx_sect,"sfx",sfx_volume);
7331 zc_set_config(sfx_sect,"emusic",emusic_volume);
7332 zc_set_config(sfx_sect,"pan",pan_style);
7333 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7334 }
7335 else
7336 {
7337 midi_volume = m;
7338 digi_volume = d;
7339 emusic_volume = e;
7340 zcmusic_bufsz = b;
7341 sfx_volume = s;
7342 pan_style = p;
7343 }
7344
7345 return D_O_K;
7346 }
7347
7348 int32_t queding(char const* s1, char const* s2, char const* s3)
7349 {
7350 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7351 }
7352
7353 int32_t onQuit()
7354 {
7355 if(Playing)
7356 {
7357 int32_t ret=0;
7358
7359 if(get_bit(quest_rules, qr_NOCONTINUE))
7360 {
7361 if(standalone_mode)
7362 {
7363 ret=queding("End current game?",
7364 "The continue screen is disabled; the game",
7365 "will be reloaded from the last save.");
7366 }
7367 else
7368 {
7369 ret=queding("End current game?",
7370 "The continue screen is disabled. You will",
7371 "be returned to the file select screen.");
7372 }
7373 }
7374 else
7375 ret=queding("End current game?",NULL,NULL);
7376
7377 if(ret==1)
7378 {
7379 disableClickToFreeze=false;
7380 Quit=qQUIT;
7381
7382 // Trying to evade a door repair charge?
7383 if(repaircharge)
7384 {
7385 game->change_drupy(-repaircharge);
7386 repaircharge=0;
7387 }
7388
7389 return D_CLOSE;
7390 }
7391 }
7392
7393 return D_O_K;
7394 }
7395
7396 int32_t onTryQuitMenu()
7397 {
7398 return onTryQuit(true);
7399 }
7400
7401 int32_t onTryQuit(bool inMenu)
7402 {
7403 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7404 {
7405 if(get_bit(quest_rules,qr_OLD_F6))
7406 {
7407 if(inMenu) onQuit();
7408 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7409 }
7410 else
7411 {
7412 disableClickToFreeze=false;
7413 GameFlags |= GAMEFLAG_TRYQUIT;
7414 }
7415 return D_CLOSE;
7416 }
7417
7418 return D_O_K;
7419 }
7420
7421 int32_t onReset()
7422 {
7423 if(queding(" Reset system? ",NULL,NULL)==1)
7424 {
7425 disableClickToFreeze=false;
7426 Quit=qRESET;
7427 replay_quit();
7428 return D_CLOSE;
7429 }
7430
7431 return D_O_K;
7432 }
7433
7434 int32_t onExit()
7435 {
7436 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7437 {
7438 Quit=qEXIT;
7439 return D_CLOSE;
7440 }
7441
7442 return D_O_K;
7443 }
7444
7445 int32_t onTitle_NES()
7446 {
7447 title_version=0;
7448 zc_set_config(cfg_sect,"title",title_version);
7449 return D_O_K;
7450 }
7451 int32_t onTitle_DX()
7452 {
7453 title_version=1;
7454 zc_set_config(cfg_sect,"title",title_version);
7455 return D_O_K;
7456 }
7457 int32_t onTitle_25()
7458 {
7459 title_version=2;
7460 zc_set_config(cfg_sect,"title",title_version);
7461 return D_O_K;
7462 }
7463
7464 int32_t onDebug()
7465 {
7466 if(debug_enabled)
7467 set_debug(!get_debug());
7468 return D_O_K;
7469 }
7470
7471 int32_t onHeartBeep()
7472 {
7473 heart_beep=!heart_beep;
7474 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7475 return D_O_K;
7476 }
7477
7478 int32_t onSaveIndicator()
7479 {
7480 use_save_indicator=!use_save_indicator;
7481 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7482 return D_O_K;
7483 }
7484
7485 int32_t onEpilepsy()
7486 {
7487 if(jwin_alert3(
7488 "Epilepsy Flash Reduction",
7489 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7490 "Disabling this will restore standard flash and wavy behaviour.",
7491 "Proceed?",
7492 "&Yes",
7493 "&No",
7494 NULL,
7495 'y',
7496 'n',
7497 0,
7498 lfont) == 1)
7499 {
7500 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7501 zc_set_config("zeldadx","checked_epilepsy",1);
7502 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7503 }
7504 return D_O_K;
7505 }
7506
7507 int32_t onTriforce()
7508 {
7509 for(int32_t i=0; i<MAXINITTABS; ++i)
7510 {
7511 init_tabs[i].flags&=~D_SELECTED;
7512 }
7513
7514 init_tabs[3].flags=D_SELECTED;
7515 return onCheatConsole();
7516 /*triforce_dlg[0].dp2=lfont;
7517 for(int32_t i=1; i<=8; i++)
7518 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7519
7520 if(zc_popup_dialog (triforce_dlg,-1)==9)
7521 {
7522 for(int32_t i=1; i<=8; i++)
7523 {
7524 game->lvlitems[i] &= ~liTRIFORCE;
7525 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7526 }
7527 }
7528 return D_O_K;*/
7529 }
7530
7531 bool rc = false;
7532 /*
7533 int32_t onEquipment()
7534 {
7535 for (int32_t i=0; i<MAXINITTABS; ++i)
7536 {
7537 init_tabs[i].flags&=~D_SELECTED;
7538 }
7539 init_tabs[0].flags=D_SELECTED;
7540 return onCheatConsole();
7541 }
7542 */
7543
7544 int32_t onItems()
7545 {
7546 for(int32_t i=0; i<MAXINITTABS; ++i)
7547 {
7548 init_tabs[i].flags&=~D_SELECTED;
7549 }
7550
7551 init_tabs[1].flags=D_SELECTED;
7552 return onCheatConsole();
7553 }
7554
7555 static DIALOG getnum_dlg[] =
7556 {
7557 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7558 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7559 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7560 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7561 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7562 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7563 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7564 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7565 };
7566
7567 int32_t getnumber(const char *prompt,int32_t initialval)
7568 {
7569 char buf[20];
7570 sprintf(buf,"%d",initialval);
7571 getnum_dlg[0].dp=(void *)prompt;
7572 getnum_dlg[0].dp2=lfont;
7573 getnum_dlg[2].dp=buf;
7574
7575 if(is_large)
7576 large_dialog(getnum_dlg);
7577
7578 if(zc_popup_dialog(getnum_dlg,2)==3)
7579 return atoi(buf);
7580
7581 return initialval;
7582 }
7583
7584 int32_t onLife()
7585 {
7586 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7587 cheats_enqueue(Cheat::Life, value);
7588 return D_O_K;
7589 }
7590
7591 int32_t onHeartC()
7592 {
7593 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7594 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7595 cheats_enqueue(Cheat::MaxLife, max_life);
7596 cheats_enqueue(Cheat::Life, life);
7597 return D_O_K;
7598 }
7599
7600 int32_t onMagicC()
7601 {
7602 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7603 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7604 cheats_enqueue(Cheat::MaxMagic, max_magic);
7605 cheats_enqueue(Cheat::Magic, magic);
7606 return D_O_K;
7607 }
7608
7609 int32_t onRupies()
7610 {
7611 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7612 cheats_enqueue(Cheat::Rupies, value);
7613 return D_O_K;
7614 }
7615
7616 int32_t onMaxBombs()
7617 {
7618 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7619 cheats_enqueue(Cheat::MaxBombs, value);
7620 cheats_enqueue(Cheat::Bombs, value);
7621 return D_O_K;
7622 }
7623
7624 int32_t onRefillLife()
7625 {
7626 cheats_enqueue(Cheat::Life, game->get_maxlife());
7627 return D_O_K;
7628 }
7629 int32_t onRefillMagic()
7630 {
7631 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7632 return D_O_K;
7633 }
7634 int32_t onClock()
7635 {
7636 cheats_enqueue(Cheat::Clock);
7637 return D_O_K;
7638 }
7639
7640 int32_t onQstPath()
7641 {
7642 char path[2048];
7643
7644 chop_path(qstdir);
7645 strcpy(path,qstdir);
7646
7647 go();
7648
7649 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7650 {
7651 chop_path(path);
7652 fix_filename_case(path);
7653 fix_filename_slashes(path);
7654 strcpy(qstdir,path);
7655 strcpy(qstpath,qstdir);
7656 }
7657
7658 comeback();
7659 return D_O_K;
7660 }
7661
7662 #include "dialog/cheat_dialog.h"
7663 int32_t onCheat()
7664 {
7665 call_setcheat_dialog();
7666 game->set_cheat(maxcheat);
7667 if(cheat) game->did_cheat(true);
7668 return D_O_K;
7669 }
7670
7671 int32_t onCheatRupies()
7672 {
7673 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7674 return D_O_K;
7675 }
7676
7677 int32_t onCheatArrows()
7678 {
7679 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7680 return D_O_K;
7681 }
7682
7683 int32_t onCheatBombs()
7684 {
7685 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7686 return D_O_K;
7687 }
7688
7689 // *** screen saver
7690
7691 4167328 int32_t after_time()
7692 {
7693
1/2
✓ Branch 0 taken 4167328 times.
✗ Branch 1 not taken.
4167328 if(ss_enable == 0)
7694 return INT_MAX;
7695
7696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
4167328 if(ss_after <= 0)
7697 return 5 * 60;
7698
7699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
4167328 if(ss_after <= 3)
7700 return ss_after * 15 * 60;
7701
7702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4167328 times.
4167328 if(ss_after <= 13)
7703 return (ss_after - 3) * 60 * 60;
7704
7705 4167328 return MAX_IDLE + 1;
7706 4167328 }
7707
7708 static const char *after_str[15] =
7709 {
7710 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7711 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7712 "Never"
7713 };
7714
7715 const char *after_list(int32_t index, int32_t *list_size)
7716 {
7717 if(index < 0)
7718 {
7719 *list_size = 15;
7720 return NULL;
7721 }
7722
7723 return after_str[index];
7724 }
7725
7726 15 static ListData after__list(after_list, &font);
7727
7728 static DIALOG scrsaver_dlg[] =
7729 {
7730 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7731 15 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7732 15 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7733 15 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7734 15 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7735 15 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7736 15 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7737 15 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7738 15 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7739 15 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7740 15 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7741 15 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7742 15 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7743 15 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7744 };
7745
7746 int32_t onScreenSaver()
7747 {
7748 scrsaver_dlg[0].dp2=lfont;
7749 int32_t oldcfgs[3];
7750 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7751 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7752 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7753
7754 if(is_large)
7755 large_dialog(scrsaver_dlg);
7756
7757 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7758
7759 if(ret == 8 || ret == 9)
7760 {
7761 ss_after = scrsaver_dlg[5].d1;
7762 ss_speed = scrsaver_dlg[6].d2;
7763 ss_density = scrsaver_dlg[7].d2;
7764 if(oldcfgs[0] != ss_after)
7765 zc_set_config(cfg_sect,"ss_after",ss_after);
7766 if(oldcfgs[1] != ss_speed)
7767 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7768 if(oldcfgs[2] != ss_density)
7769 zc_set_config(cfg_sect,"ss_density",ss_density);
7770 }
7771
7772 if(ret == 9)
7773 // preview Screen Saver
7774 {
7775 clear_keybuf();
7776 scare_mouse();
7777 Matrix(ss_speed, ss_density, 30);
7778 system_pal();
7779 unscare_mouse();
7780 }
7781
7782 return D_O_K;
7783 }
7784
7785 /***** Menus *****/
7786
7787 static MENU game_menu[] =
7788 {
7789 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7790 { (char *)"", NULL, NULL, 0, NULL },
7791 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7792 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7793 { (char *)"", NULL, NULL, 0, NULL },
7794 #ifdef __EMSCRIPTEN__
7795 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7796 #elif defined(ALLEGRO_MACOSX)
7797 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7798 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7799 #else
7800 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7801 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7802 #endif
7803 { NULL, NULL, NULL, 0, NULL }
7804 };
7805
7806 static MENU title_menu[] =
7807 {
7808 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7809 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7810 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7811 { NULL, NULL, NULL, 0, NULL }
7812 };
7813
7814 static MENU snapshot_format_menu[] =
7815 {
7816 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7817 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7818 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7819 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7820 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7821 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7822 { NULL, NULL, NULL, 0, NULL }
7823 };
7824
7825 static MENU controls_menu[] =
7826 {
7827 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7828 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7829 { NULL, NULL, NULL, 0, NULL }
7830 };
7831
7832 static MENU name_entry_mode_menu[] =
7833 {
7834 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7835 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7836 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7837 { NULL, NULL, NULL, 0, NULL }
7838 };
7839
7840 static void set_controls_menu_active()
7841 {
7842
7843 }
7844
7845 static MENU settings_menu[] =
7846 {
7847 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7848 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7849 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7850 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7851 { (char *)"", NULL, NULL, 0, NULL },
7852 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7853 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7854 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7855 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7856 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7857 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7858 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7859 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7860 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7861 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7862 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7863 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7864 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7865 { (char *)"", NULL, NULL, 0, NULL },
7866 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7867 { (char *)"", NULL, NULL, 0, NULL },
7868 { NULL, NULL, NULL, 0, NULL }
7869 };
7870
7871
7872 static MENU misc_menu[] =
7873 {
7874 { (char *)"&About...", onAbout, NULL, 0, NULL },
7875 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7876 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7877 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7878 { (char *)"", NULL, NULL, 0, NULL },
7879 //5
7880 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7881 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7882 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7883 { (char *)"", NULL, NULL, 0, NULL },
7884 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7885 //10
7886 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7887 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7888 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7889 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7890 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7891 //15
7892 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7893 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7894 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7895
7896 { NULL, NULL, NULL, 0, NULL }
7897 };
7898
7899 static MENU refill_menu[] =
7900 {
7901 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7902 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7903 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7904 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7905 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7906 { NULL, NULL, NULL, 0, NULL }
7907 };
7908
7909 static MENU show_menu[] =
7910 {
7911 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7912 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7913 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7914 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7915 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7916 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7917 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7918 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7919 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7920 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7921 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7922 { (char *)"", NULL, NULL, 0, NULL },
7923 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7924 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7925 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7926 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7927 { NULL, NULL, NULL, 0, NULL }
7928 };
7929
7930 static MENU cheat_menu[] =
7931 {
7932 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7933 { (char *)"", NULL, NULL, 0, NULL },
7934 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7935 { (char *)"", NULL, NULL, 0, NULL },
7936 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7937 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7938 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7939 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7940 { (char *)"", NULL, NULL, 0, NULL },
7941 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7942 { (char *)"", NULL, NULL, 0, NULL },
7943 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7944 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7945 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7946 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7947 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7948 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7949 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7950 { NULL, NULL, NULL, 0, NULL }
7951 };
7952
7953 static MENU fixes_menu[] =
7954 {
7955 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7956 { NULL, NULL, NULL, 0, NULL }
7957 };
7958
7959 #if DEVLEVEL > 0
7960 int32_t devLogging();
7961 int32_t devDebug();
7962 int32_t devTimestmp();
7963 #if DEVLEVEL > 1
7964 int32_t setCheat();
7965 #endif //DEVLEVEL > 1
7966 enum
7967 {
7968 dv_log,
7969 // dv_dbg,
7970 dv_tmpstmp,
7971 #if DEVLEVEL > 1
7972 dv_nil,
7973 dv_setcheat,
7974 #endif //DEVLEVEL > 1
7975 dv_max
7976 };
7977 static MENU dev_menu[] =
7978 {
7979 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7980 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7981 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7982 #if DEVLEVEL > 1
7983 { (char *)"", NULL, NULL, 0, NULL },
7984 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7985 #endif //DEVLEVEL > 1
7986 { NULL, NULL, NULL, 0, NULL }
7987 };
7988 int32_t devLogging()
7989 {
7990 dev_logging = !dev_logging;
7991 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7992 return D_O_K;
7993 }
7994 // int32_t devDebug()
7995 // {
7996 // dev_debug = !dev_debug;
7997 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7998 // return D_O_K;
7999 // }
8000 int32_t devTimestmp()
8001 {
8002 dev_timestmp = !dev_timestmp;
8003 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8004 return D_O_K;
8005 }
8006 #if DEVLEVEL > 1
8007 int32_t setCheat()
8008 {
8009 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8010 return D_O_K;
8011 }
8012 #endif //DEVLEVEL > 1
8013 #endif //DEVLEVEL > 0
8014
8015 MENU the_player_menu[] =
8016 {
8017 { (char *)"&Game", NULL, game_menu, 0, NULL },
8018 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8019 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8020 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8021 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8022 #if DEVLEVEL > 0
8023 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8024 #endif
8025 { NULL, NULL, NULL, 0, NULL }
8026 };
8027
8028 MENU the_player_menu2[] =
8029 {
8030 { (char *)"&Game", NULL, game_menu, 0, NULL },
8031 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8032 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8033 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8034 #if DEVLEVEL > 0
8035 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8036 #endif
8037 { NULL, NULL, NULL, 0, NULL }
8038 };
8039
8040 int32_t onMIDIPatch()
8041 {
8042 if(jwin_alert3(
8043 "Toggle Windows MIDI Fix",
8044 "This action will change whether ZC Player auto-restarts a MIDI at its",
8045 "last index if you move ZC Player out of focus, then back into focus.",
8046 "Proceed?",
8047 "&Yes",
8048 "&No",
8049 NULL,
8050 'y',
8051 'n',
8052 0,
8053 lfont) == 1)
8054 {
8055 midi_patch_fix = midi_patch_fix ? 0 : 1;
8056 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8057 }
8058 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8059 return D_O_K;
8060 }
8061
8062 int32_t onKeyboardEntry()
8063 {
8064 NameEntryMode=0;
8065 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8066 return D_O_K;
8067 }
8068
8069 int32_t onLetterGridEntry()
8070 {
8071 NameEntryMode=1;
8072 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8073 return D_O_K;
8074 }
8075
8076 int32_t onExtLetterGridEntry()
8077 {
8078 NameEntryMode=2;
8079 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8080 return D_O_K;
8081 }
8082
8083 static BITMAP* oldscreen;
8084 int32_t onFullscreenMenu()
8085 {
8086 // super hacks
8087 screen = oldscreen;
8088 if (onFullscreen() == D_REDRAW)
8089 {
8090 oldscreen = screen;
8091 }
8092 screen = menu_bmp;
8093 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8094 return D_O_K;
8095 }
8096
8097 15 void fix_menu()
8098 {
8099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(!debug_enabled)
8100 15 settings_menu[18].text = NULL;
8101 15 }
8102
8103 static DIALOG system_dlg[] =
8104 {
8105 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8106 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8107 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8108 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8109 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8110 #ifndef ALLEGRO_MACOSX
8111 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8112 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8113 #else
8114 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8115 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8116 #endif
8117 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8118 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8119 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8120 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8121 };
8122
8123 static DIALOG system_dlg2[] =
8124 {
8125 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8126 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8127 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8128 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8129 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8130 #ifndef ALLEGRO_MACOSX
8131 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8132 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8133 #else
8134 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8135 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8136 #endif
8137 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8138 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8139 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8140 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8141 };
8142
8143 void reset_snapshot_format_menu()
8144 {
8145 for(int32_t i=0; i<ssfmtMAX; ++i)
8146 {
8147 snapshot_format_menu[i].flags=0;
8148 }
8149 }
8150
8151 int32_t onSetSnapshotFormat()
8152 {
8153 switch(active_menu->text[1])
8154 {
8155 case 'B': //"&BMP"
8156 SnapshotFormat=0;
8157 break;
8158
8159 case 'G': //"&GIF"
8160 SnapshotFormat=1;
8161 break;
8162
8163 case 'J': //"&JPG"
8164 SnapshotFormat=2;
8165 break;
8166
8167 case 'P': //"&PNG"
8168 SnapshotFormat=3;
8169 break;
8170
8171 case 'C': //"PC&X"
8172 SnapshotFormat=4;
8173 break;
8174
8175 case 'T': //"&TGA"
8176 SnapshotFormat=5;
8177 break;
8178
8179 case 'L': //"&LBM"
8180 SnapshotFormat=6;
8181 break;
8182 }
8183 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8184
8185 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8186 return D_O_K;
8187 }
8188
8189
8190 29 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8191 {
8192 PALETTE tmp;
8193
8194
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<256; i++)
8195 {
8196 7424 tmp[i].r=r;
8197 7424 tmp[i].g=g;
8198 7424 tmp[i].b=b;
8199 7424 }
8200
8201 29 fade_interpolate(src,tmp,dest,pos,from,to);
8202 29 }
8203
8204 29 void system_pal()
8205 {
8206 29 is_sys_pal = true;
8207 static PALETTE pal;
8208 29 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8209
8210 // set up the grayscale palette
8211
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 29 times.
1885 for(int32_t i=128; i<192; i++)
8212 {
8213 1856 pal[i].r = i-128;
8214 1856 pal[i].g = i-128;
8215 1856 pal[i].b = i-128;
8216 1856 }
8217 29 load_colorset(gui_colorset, pal);
8218
8219 29 color_layer(pal, pal, 24,16,16, 28, 128,191);
8220
8221
2/2
✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 29 times.
3741 for(int32_t i=0; i<256; i+=2)
8222 {
8223 3712 int32_t v = (i>>3)+2;
8224 3712 int32_t c = (i>>3)+192;
8225 3712 pal[c] = _RGB(v,v,v+(v>>1));
8226 /*
8227 if(i<240)
8228 {
8229 _allegro_hline(tmp_scr,0,i,319,c);
8230 _allegro_hline(tmp_scr,0,i+1,319,c);
8231 }
8232 */
8233 3712 }
8234
8235 // draw the vertical screen gradient
8236
2/2
✓ Branch 0 taken 6960 times.
✓ Branch 1 taken 29 times.
6989 for(int32_t i=0; i<240; ++i)
8237 {
8238 6960 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8239 6960 }
8240
8241 /*
8242 palrstart= 10*63/255; palrend=166*63/255;
8243 palgstart= 36*63/255; palgend=202*63/255;
8244 palbstart=106*63/255; palbend=240*63/255;
8245 paldivs=32;
8246 for(int32_t i=0; i<paldivs; i++)
8247 {
8248 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8249 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8250 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8251 }
8252 */
8253 29 BITMAP *panorama = create_bitmap_ex(8,256,224);
8254 int32_t ts_height, ts_start;
8255
8256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8257 {
8258 clear_to_color(panorama,0);
8259 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8260 ts_height=224-passive_subscreen_height;
8261 ts_start=28;
8262 }
8263 else
8264 {
8265 29 blit(framebuf,panorama,0,0,0,0,256,224);
8266 29 ts_height=224;
8267 29 ts_start=0;
8268 }
8269
8270 // gray scale the current frame
8271
2/2
✓ Branch 0 taken 6496 times.
✓ Branch 1 taken 29 times.
6525 for(int32_t y=0; y<ts_height; y++)
8272 {
8273
2/2
✓ Branch 0 taken 1662976 times.
✓ Branch 1 taken 6496 times.
1669472 for(int32_t x=0; x<256; x++)
8274 {
8275 1662976 int32_t c = panorama->line[y+ts_start][x];
8276
2/2
✓ Branch 0 taken 1657086 times.
✓ Branch 1 taken 5890 times.
1662976 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8277 1662976 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8278 1662976 }
8279 6496 }
8280
8281 29 destroy_bitmap(panorama);
8282
8283 // display everything
8284 29 vsync();
8285 29 hw_palette = &pal;
8286 29 update_hw_pal = true;
8287
8288 // sys_pal = pal;
8289 29 memcpy(sys_pal,pal,sizeof(pal));
8290 29 }
8291
8292 void system_pal2()
8293 {
8294 is_sys_pal = true;
8295 static PALETTE RAMpal2;
8296 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8297
8298 /* Windows 2000 colors
8299 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8300 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8301 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8302 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8303 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8304 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8305 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8306 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8307
8308 byte palrstart= 10*63/255, palrend=166*63/255,
8309 palgstart= 36*63/255, palgend=202*63/255,
8310 palbstart=106*63/255, palbend=240*63/255,
8311 paldivs=7;
8312 for(int32_t i=0; i<paldivs; i++)
8313 {
8314 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8315 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8316 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8317 }
8318 */
8319
8320 /* Windows 98 colors
8321 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8322 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8323 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8324 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8325 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8326 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8327 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8328 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8329
8330 byte palrstart= 0*63/255, palrend=166*63/255,
8331 palgstart= 0*63/255, palgend=202*63/255,
8332 palbstart=128*63/255, palbend=240*63/255,
8333 paldivs=7;
8334 for(int32_t i=0; i<paldivs; i++)
8335 {
8336 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8337 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8338 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8339 }
8340 */
8341
8342 /* Windows 99 colors
8343 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8344 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8345 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8346 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8347 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8348 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8349 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8350 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8351 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8352
8353 byte palrstart= 0*63/255, palrend=166*63/255,
8354 palgstart= 0*63/255, palgend=202*63/255,
8355
8356 palbstart=128*63/255, palbend=240*63/255,
8357 paldivs=6;
8358 for(int32_t i=0; i<paldivs; i++)
8359 {
8360 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8361 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8362 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8363 }
8364 */
8365
8366
8367
8368 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8369 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8370 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8371 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8372 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8373 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8374 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8375 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8376 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8377
8378 byte palrstart= 0*63/255, palrend=166*63/255,
8379 palgstart= 0*63/255, palgend=202*63/255,
8380 palbstart=128*63/255, palbend=240*63/255,
8381 paldivs=6;
8382
8383 for(int32_t i=0; i<paldivs; i++)
8384 {
8385 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8386 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8387 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8388 }
8389
8390 gui_bg_color=jwin_pal[jcBOX];
8391 gui_fg_color=jwin_pal[jcBOXFG];
8392
8393 jwin_set_colors(jwin_pal);
8394
8395
8396 // set up the new palette
8397 for(int32_t i=128; i<192; i++)
8398 {
8399 RAMpal2[i].r = i-128;
8400 RAMpal2[i].g = i-128;
8401 RAMpal2[i].b = i-128;
8402 }
8403
8404 /*
8405 for(int32_t i=0; i<64; i++)
8406 {
8407 RAMpal2[128+i] = _RGB(i,i,i)1));
8408 }
8409 */
8410
8411 /*
8412
8413 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8414 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8415 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8416 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8417 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8418 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8419 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8420
8421 gui_fg_color=vc(14);
8422 gui_bg_color=vc(1);
8423
8424 jwin_set_colors(jwin_pal);
8425 */
8426
8427 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8428
8429 // set up the colors for the vertical screen gradient
8430 for(int32_t i=0; i<256; i+=2)
8431 {
8432 int32_t v = (i>>3)+2;
8433 int32_t c = (i>>3)+192;
8434 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8435
8436 /*
8437 if(i<240)
8438 {
8439 _allegro_hline(tmp_scr,0,i,319,c);
8440 _allegro_hline(tmp_scr,0,i+1,319,c);
8441 }
8442 */
8443 }
8444
8445 // hw_palette = &RAMpal;
8446 // update_hw_pal = true;
8447
8448 for(int32_t i=0; i<240; ++i)
8449 {
8450 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8451 }
8452
8453 /*
8454 byte palrstart= 10*63/255, palrend=166*63/255,
8455 palgstart= 36*63/255, palgend=202*63/255,
8456 palbstart=106*63/255, palbend=240*63/255,
8457 paldivs=32;
8458 for(int32_t i=0; i<paldivs; i++)
8459 {
8460 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8461 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8462 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8463 }
8464 */
8465 BITMAP *panorama = create_bitmap_ex(8,256,224);
8466 int32_t ts_height, ts_start;
8467
8468 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8469 {
8470 clear_to_color(panorama,0);
8471 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8472 ts_height=224-passive_subscreen_height;
8473 ts_start=28;
8474 }
8475 else
8476 {
8477 blit(framebuf,panorama,0,0,0,0,256,224);
8478 ts_height=224;
8479 ts_start=0;
8480 }
8481
8482 // gray scale the current frame
8483 for(int32_t y=0; y<ts_height; y++)
8484 {
8485 for(int32_t x=0; x<256; x++)
8486 {
8487 int32_t c = panorama->line[y+ts_start][x];
8488 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8489 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8490 }
8491 }
8492
8493 destroy_bitmap(panorama);
8494
8495 // display everything
8496 vsync();
8497 hw_palette = &RAMpal2;
8498 update_hw_pal = true;
8499
8500 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8501
8502 // sys_pal = pal;
8503 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8504 }
8505
8506 static uint32_t entered_sys_pal = 0;
8507 14 void enter_sys_pal()
8508 {
8509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8510 {
8511 if(entered_sys_pal)
8512 ++entered_sys_pal;
8513 return;
8514 }
8515 14 system_pal();
8516 14 ++entered_sys_pal;
8517 14 }
8518 14 void exit_sys_pal()
8519 {
8520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8521 {
8522
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8523 {
8524 14 game_pal();
8525 14 }
8526 14 }
8527 14 }
8528
8529 void switch_out_callback()
8530 {
8531 if (pause_in_background)
8532 {
8533 callback_switchin = 3;
8534 return;
8535 }
8536
8537 #ifdef _WIN32
8538 if(midi_patch_fix==0 || currmidi==-1)
8539 return;
8540
8541
8542 paused_midi_pos = midi_pos;
8543 zc_stop_midi();
8544 midi_paused=true;
8545 midi_suspended = midissuspHALTED;
8546 #endif
8547 }
8548
8549 void switch_in_callback()
8550 {
8551 if(pause_in_background)
8552 {
8553 return;
8554 }
8555
8556 #ifdef _WIN32
8557 if(midi_patch_fix==0 || currmidi==-1)
8558 return;
8559
8560 else
8561 {
8562 callback_switchin = 1;
8563 midi_suspended = midissuspRESUME;
8564 }
8565 #endif
8566 }
8567
8568 171 void game_pal()
8569 {
8570 171 is_sys_pal = false;
8571 171 entered_sys_pal = 0;
8572 171 clear_to_color(screen,BLACK);
8573 171 hw_palette = &RAMpal;
8574 171 update_hw_pal = true;
8575 171 }
8576
8577 static char bar_str[] = "";
8578
8579 14 void music_pause()
8580 {
8581 //al_pause_duh(tmplayer);
8582 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8583 14 zc_midi_pause();
8584 14 midi_paused=true;
8585 14 }
8586
8587 void music_resume()
8588 {
8589 //al_resume_duh(tmplayer);
8590 zcmusic_pause(zcmusic, ZCM_RESUME);
8591 zc_midi_resume();
8592 midi_paused=false;
8593 }
8594
8595 3121 void music_stop()
8596 {
8597 //al_stop_duh(tmplayer);
8598 //unload_duh(tmusic);
8599 //tmusic=NULL;
8600 //tmplayer=NULL;
8601 3121 zcmusic_stop(zcmusic);
8602 3121 zcmusic_unload_file(zcmusic);
8603 3121 zc_stop_midi();
8604 3121 midi_paused=false;
8605 3121 currmidi=-1;
8606 3121 }
8607
8608 void System()
8609 {
8610 mouse_down=gui_mouse_b();
8611 music_pause();
8612 pause_all_sfx();
8613 MenuOpen = true;
8614 system_pal();
8615 // FONT *oldfont=font;
8616 // font=tfont;
8617
8618 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8619 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8620
8621 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8622 #if DEVLEVEL > 1
8623 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8624 #endif
8625 game_menu[3].flags =
8626 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8627 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8628 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8629 clear_keybuf();
8630 show_mouse(screen);
8631
8632 DIALOG_PLAYER *p;
8633
8634 clear_bitmap(menu_bmp);
8635 oldscreen = screen;
8636 screen = menu_bmp;
8637
8638 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8639 {
8640 p = init_dialog(system_dlg2,-1);
8641 }
8642 else
8643 {
8644 p = init_dialog(system_dlg,-1);
8645 }
8646
8647 // drop the menu on startup if menu button pressed
8648 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8649 simulate_keypress(KEY_G << 8);
8650
8651 do
8652 {
8653 if(close_button_quit)
8654 {
8655 close_button_quit = false;
8656 f_Quit(qEXIT);
8657 if(Quit) break;
8658 }
8659 rest(17);
8660
8661 if(mouse_down && !gui_mouse_b())
8662 mouse_down=0;
8663
8664 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8665 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8666 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8667
8668 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8669 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8670 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8671 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8672 settings_menu[8].flags = NESquit?D_SELECTED:0;
8673 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8674 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8675 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8676 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8677 settings_menu[13].flags = volkeys?D_SELECTED:0;
8678 //Epilepsy Prevention
8679 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8680
8681 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8682 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8683 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8684
8685 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8686 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8687 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8688
8689 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8690 cheat_menu[0].flags = 0;
8691 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8692 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8693 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8694 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8695 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8696 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8697 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8698 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8699 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8700
8701 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8702 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8703 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8704 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8705 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8706 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8707 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8708 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8709 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8710 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8711 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8712 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8713 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8714 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8715 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8716
8717 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8718 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8719
8720 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8721 (char *)"Disable recording new saves" :
8722 (char *)"Enable recording new saves";
8723 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8724 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8725 (char *)"Stop recording" :
8726 (char *)"Stop replaying";
8727 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8728 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8729 (char *)"Disable snapshot all frames" :
8730 (char *)"Enable snapshot all frames";
8731
8732 reset_snapshot_format_menu();
8733 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8734
8735 if(debug_enabled)
8736 {
8737 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8738 }
8739
8740 if(gui_mouse_b() && !mouse_down)
8741 break;
8742
8743 // press menu to drop the menu
8744 if(rMbtn())
8745 simulate_keypress(KEY_G << 8);
8746
8747 if(input_idle(true) > after_time())
8748 // run Screeen Saver
8749 {
8750 // Screen saver enabled for now.
8751 clear_keybuf();
8752 scare_mouse();
8753 Matrix(ss_speed, ss_density, 0);
8754 system_pal();
8755 unscare_mouse();
8756 broadcast_dialog_message(MSG_DRAW, 0);
8757 }
8758
8759 update_hw_screen();
8760 }
8761 while(update_dialog(p));
8762
8763 screen = oldscreen;
8764
8765 // font=oldfont;
8766 mouse_down=gui_mouse_b();
8767 shutdown_dialog(p);
8768 show_mouse(NULL);
8769 MenuOpen = false;
8770 if(Quit)
8771 {
8772 kill_sfx();
8773 music_stop();
8774 update_hw_screen();
8775 }
8776 else
8777 {
8778 game_pal();
8779 music_resume();
8780 resume_all_sfx();
8781
8782 if(rc)
8783 ringcolor(false);
8784 }
8785
8786 eat_buttons();
8787
8788 rc=false;
8789 clear_keybuf();
8790 // text_mode(0);
8791 }
8792
8793 15 void fix_dialogs()
8794 {
8795 15 jwin_center_dialog(about_dlg);
8796 15 jwin_center_dialog(gamepad_dlg);
8797 15 jwin_center_dialog(credits_dlg);
8798 15 jwin_center_dialog(gamemode_dlg);
8799 15 jwin_center_dialog(getnum_dlg);
8800 15 jwin_center_dialog(goto_dlg);
8801 15 jwin_center_dialog(keyboard_control_dlg);
8802 15 jwin_center_dialog(midi_dlg);
8803 15 jwin_center_dialog(quest_dlg);
8804 15 jwin_center_dialog(scrsaver_dlg);
8805 15 jwin_center_dialog(sound_dlg);
8806 15 jwin_center_dialog(triforce_dlg);
8807
8808 // digi_dp[1] += scrx;
8809 // digi_dp[2] += scry;
8810 // midi_dp[1] += scrx;
8811 // midi_dp[2] += scry;
8812 // pan_dp[1] += scrx;
8813 // pan_dp[2] += scry;
8814 // emus_dp[1] += scrx;
8815 // emus_dp[2] += scry;
8816 // buf_dp[1] += scrx;
8817 // buf_dp[2] += scry;
8818 // sfx_dp[1] += scrx;
8819 // sfx_dp[2] += scry;
8820 15 }
8821
8822 /*****************************/
8823 /**** Custom Sound System ****/
8824 /*****************************/
8825
8826 1289 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8827 {
8828
3/4
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 1289 times.
✗ Branch 3 not taken.
1289 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8829 }
8830
8831 // Run an NSF, or a MIDI if the NSF is missing somehow.
8832 59 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8833 {
8834 59 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8835
8836 // Found it
8837
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 20 times.
59 if(newzcmusic!=NULL)
8838 {
8839 39 zcmusic_stop(zcmusic);
8840 39 zcmusic_unload_file(zcmusic);
8841 39 zc_stop_midi();
8842
8843 39 zcmusic=newzcmusic;
8844 39 zcmusic_play(zcmusic, emusic_volume);
8845
8846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(track>0)
8847 39 zcmusic_change_track(zcmusic,track);
8848
8849 39 return true;
8850 }
8851
8852 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8853
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 else if(midi>-1000)
8854 jukebox(midi);
8855
8856 20 return false;
8857 59 }
8858
8859 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8860 {
8861 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8862 // Found it
8863 if(newzcmusic!=NULL)
8864 {
8865 zcmusic_stop(zcmusic);
8866 zcmusic_unload_file(zcmusic);
8867 zc_stop_midi();
8868
8869 zcmusic=newzcmusic;
8870 zcmusic_play(zcmusic, emusic_volume);
8871
8872 if(track>0)
8873 zcmusic_change_track(zcmusic,track);
8874
8875 return true;
8876 }
8877
8878 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8879 else if(midi>-1000)
8880 jukebox(midi);
8881
8882 return false;
8883 }
8884
8885 int32_t get_zcmusicpos()
8886 {
8887 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8888 return debugtracething;
8889 return 0;
8890 }
8891
8892 void set_zcmusicpos(int32_t position)
8893 {
8894 zcmusic_set_curpos(zcmusic, position);
8895 }
8896
8897 void set_zcmusicspeed(int32_t speed)
8898 {
8899 int32_t newspeed = vbound(speed, 0, 10000);
8900 zcmusic_set_speed(zcmusic, newspeed);
8901 }
8902
8903 637 void jukebox(int32_t index,int32_t loop)
8904 {
8905 637 music_stop();
8906
8907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 637 times.
637 if(index<0) index=MAXMIDIS-1;
8908
8909
1/2
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
637 if(index>=MAXMIDIS) index=0;
8910
8911 637 music_stop();
8912
8913 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8914 // stuck notes when a song stops. This fixes it.
8915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 637 times.
637 if(strcmp(midi_driver->name, "DIGMID")==0)
8916 zc_set_volume(0, 0);
8917
8918 637 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8919 637 zc_play_midi((MIDI*)tunes[index].data,loop);
8920
8921
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 141 times.
637 if(tunes[index].start>0)
8922 141 zc_midi_seek(tunes[index].start);
8923
8924 637 midi_loop_start = tunes[index].loop_start;
8925 637 midi_loop_end = tunes[index].loop_end;
8926
8927 637 currmidi=index;
8928 637 master_volume(digi_volume,midi_volume);
8929 637 midi_paused=false;
8930 637 }
8931
8932 4600 void jukebox(int32_t index)
8933 {
8934
1/2
✓ Branch 0 taken 4600 times.
✗ Branch 1 not taken.
4600 if(index<0) index=MAXMIDIS-1;
8935
8936
1/2
✓ Branch 0 taken 4600 times.
✗ Branch 1 not taken.
4600 if(index>=MAXMIDIS) index=0;
8937
8938 // do nothing if it's already playing
8939
3/4
✓ Branch 0 taken 3963 times.
✓ Branch 1 taken 637 times.
✓ Branch 2 taken 3963 times.
✗ Branch 3 not taken.
4600 if(index==currmidi && midi_pos>=0)
8940 {
8941 3963 midi_paused=false;
8942 3963 return;
8943 }
8944
8945 637 jukebox(index,tunes[index].loop);
8946 4600 }
8947
8948 5243 void play_DmapMusic()
8949 {
8950 static char tfile[2048];
8951 static int32_t ttrack=0;
8952 5243 bool domidi=false;
8953
8954
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 4490 times.
5243 if(DMaps[currdmap].tmusic[0]!=0)
8955 {
8956
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1138 if(zcmusic==NULL ||
8957
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8958
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8959 {
8960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(zcmusic != NULL)
8961 {
8962 zcmusic_stop(zcmusic);
8963 zcmusic_unload_file(zcmusic);
8964 zcmusic = NULL;
8965 }
8966
8967 368 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8968
8969
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 282 times.
368 if(zcmusic!=NULL)
8970 {
8971 86 zc_stop_midi();
8972 86 strcpy(tfile,DMaps[currdmap].tmusic);
8973 86 zcmusic_play(zcmusic, emusic_volume);
8974 86 int32_t temptracks=0;
8975 86 temptracks=zcmusic_get_tracks(zcmusic);
8976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8977 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8978 86 zcmusic_change_track(zcmusic,ttrack);
8979 86 }
8980 else
8981 {
8982 282 tfile[0] = 0;
8983 282 domidi=true;
8984 }
8985 368 }
8986 753 }
8987 else
8988 {
8989 4490 domidi=true;
8990 }
8991
8992
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 4772 times.
5243 if(domidi)
8993 {
8994 4772 int32_t m=DMaps[currdmap].midi;
8995
8996
3/4
✓ Branch 0 taken 4681 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
4772 switch(m)
8997 {
8998 case 1:
8999 81 jukebox(ZC_MIDI_OVERWORLD);
9000 81 break;
9001
9002 case 2:
9003 10 jukebox(ZC_MIDI_DUNGEON);
9004 10 break;
9005
9006 case 3:
9007 jukebox(ZC_MIDI_LEVEL9);
9008 break;
9009
9010 default:
9011
3/4
✓ Branch 0 taken 4389 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4389 times.
4681 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9012 4389 jukebox(m+MIDIOFFSET_DMAP);
9013 else
9014 292 music_stop();
9015 4681 }
9016 4772 }
9017 5243 }
9018
9019 5279 void playLevelMusic()
9020 {
9021 5279 int32_t m=tmpscr->screen_midi;
9022
9023
3/6
✓ Branch 0 taken 5227 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
5279 switch(m)
9024 {
9025 case -2:
9026 11 music_stop();
9027 11 break;
9028
9029 case -1:
9030 5227 play_DmapMusic();
9031 5227 break;
9032
9033 case 1:
9034 jukebox(ZC_MIDI_OVERWORLD);
9035 break;
9036
9037 case 2:
9038 jukebox(ZC_MIDI_DUNGEON);
9039 break;
9040
9041 case 3:
9042 jukebox(ZC_MIDI_LEVEL9);
9043 break;
9044
9045 default:
9046
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9047 41 jukebox(m+MIDIOFFSET_MAPSCR);
9048 else
9049 music_stop();
9050 41 }
9051 5279 }
9052
9053 652 void master_volume(int32_t dv,int32_t mv)
9054 {
9055
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 652 times.
✓ Branch 2 taken 652 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 652 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 652 times.
✗ Branch 7 not taken.
652 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9056
9057
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 652 times.
✓ Branch 2 taken 652 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 652 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 652 times.
✗ Branch 7 not taken.
652 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9058
9059
6/6
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 651 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 635 times.
✓ Branch 5 taken 16 times.
652 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9060 652 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9061 652 }
9062
9063 /*****************/
9064 /***** SFX *****/
9065 /*****************/
9066
9067 // array of voices, one for each sfx sample in the data file
9068 // 0+ = voice #
9069 // -1 = voice not allocated
9070 15 void Z_init_sound()
9071 {
9072
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 15 times.
3855 for(int32_t i=0; i<WAV_COUNT; i++)
9073 3840 sfx_voice[i]=-1;
9074
9075
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 15 times.
120 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9076 105 tunes[i].data = (MIDI*)mididata[i].dat;
9077
9078
2/2
✓ Branch 0 taken 3780 times.
✓ Branch 1 taken 15 times.
3795 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9079 3780 tunes[ZC_MIDI_COUNT+j].data=NULL;
9080
9081 15 master_volume(digi_volume,midi_volume);
9082 15 }
9083
9084 // returns number of voices currently allocated
9085 int32_t sfx_count()
9086 {
9087 int32_t c=0;
9088
9089 for(int32_t i=0; i<WAV_COUNT; i++)
9090 if(sfx_voice[i]!=-1)
9091 ++c;
9092
9093 return c;
9094 }
9095
9096 // clean up finished samples
9097 4103174 void sfx_cleanup()
9098 {
9099
2/2
✓ Branch 0 taken 1050412544 times.
✓ Branch 1 taken 4103174 times.
1054515718 for(int32_t i=0; i<WAV_COUNT; i++)
9100
3/4
✓ Branch 0 taken 390153 times.
✓ Branch 1 taken 1050022391 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 390153 times.
1050802697 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9101 {
9102 390153 deallocate_voice(sfx_voice[i]);
9103 390153 sfx_voice[i]=-1;
9104 390153 }
9105 4103174 }
9106
9107 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9108 // if a voice is already allocated (and/or playing), then it just returns true
9109 // Returns true: voice is allocated
9110 // false: unsuccessful
9111 485722 bool sfx_init(int32_t index)
9112 {
9113 // check index
9114
3/4
✓ Branch 0 taken 427423 times.
✓ Branch 1 taken 58299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 427423 times.
485722 if(index<=0 || index>=WAV_COUNT)
9115 58299 return false;
9116
9117
2/2
✓ Branch 0 taken 37251 times.
✓ Branch 1 taken 390172 times.
427423 if(sfx_voice[index]==-1)
9118 {
9119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390172 times.
390172 if(sfxdat)
9120 {
9121 if(index<Z35)
9122 {
9123 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9124 }
9125 else
9126 {
9127 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9128 }
9129 }
9130 else
9131 {
9132 390172 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9133 }
9134
9135 390172 voice_set_volume(sfx_voice[index], sfx_volume);
9136 390172 }
9137
9138 427423 return sfx_voice[index] != -1;
9139 485722 }
9140
9141 // plays an sfx sample
9142 399142 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9143 {
9144
2/2
✓ Branch 0 taken 371073 times.
✓ Branch 1 taken 28069 times.
399142 if(!sfx_init(index))
9145 28069 return;
9146
9147 371073 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9148 371073 voice_set_pan(sfx_voice[index],pan);
9149
9150 371073 int32_t pos = voice_get_position(sfx_voice[index]);
9151
9152
2/2
✓ Branch 0 taken 207012 times.
✓ Branch 1 taken 164061 times.
371073 if(restart) voice_set_position(sfx_voice[index],0);
9153
9154
1/2
✓ Branch 0 taken 371073 times.
✗ Branch 1 not taken.
371073 if(pos<=0)
9155 371073 voice_start(sfx_voice[index]);
9156 399142 }
9157
9158 // true if sfx is allocated
9159 5 bool sfx_allocated(int32_t index)
9160 {
9161
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9162 }
9163
9164 // start it (in loop mode) if it's not already playing,
9165 // otherwise adjust it to play in loop mode -DD
9166 86580 void cont_sfx(int32_t index)
9167 {
9168
2/2
✓ Branch 0 taken 30230 times.
✓ Branch 1 taken 56350 times.
86580 if(!sfx_init(index))
9169 {
9170 30230 return;
9171 }
9172
9173
1/2
✓ Branch 0 taken 56350 times.
✗ Branch 1 not taken.
56350 if(voice_get_position(sfx_voice[index])<=0)
9174 {
9175 56350 voice_set_position(sfx_voice[index],0);
9176 56350 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9177 56350 voice_start(sfx_voice[index]);
9178 56350 }
9179 else
9180 {
9181 adjust_sfx(index, 128, true);
9182 }
9183 86580 }
9184
9185 // adjust parameters while playing
9186 2660 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9187 {
9188
5/6
✓ Branch 0 taken 1494 times.
✓ Branch 1 taken 1166 times.
✓ Branch 2 taken 1494 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1482 times.
2660 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9189 2648 return;
9190
9191 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9192 12 voice_set_pan(sfx_voice[index],pan);
9193 2660 }
9194
9195 // pauses a voice
9196 954 void pause_sfx(int32_t index)
9197 {
9198
3/6
✓ Branch 0 taken 954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 954 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 954 times.
954 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9199 voice_stop(sfx_voice[index]);
9200 954 }
9201
9202 // resumes a voice
9203 452 void resume_sfx(int32_t index)
9204 {
9205
3/6
✓ Branch 0 taken 452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 452 times.
452 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9206 voice_start(sfx_voice[index]);
9207 452 }
9208
9209 // pauses all active voices
9210 113 void pause_all_sfx()
9211 {
9212
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<WAV_COUNT; i++)
9213
2/2
✓ Branch 0 taken 28926 times.
✓ Branch 1 taken 2 times.
28930 if(sfx_voice[i]!=-1)
9214 2 voice_stop(sfx_voice[i]);
9215 113 }
9216
9217 // resumes all paused voices
9218 99 void resume_all_sfx()
9219 {
9220
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<WAV_COUNT; i++)
9221
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(sfx_voice[i]!=-1)
9222 voice_start(sfx_voice[i]);
9223 99 }
9224
9225 // stops an sfx and deallocates the voice
9226 3240439 void stop_sfx(int32_t index)
9227 {
9228
3/4
✓ Branch 0 taken 3152228 times.
✓ Branch 1 taken 88211 times.
✓ Branch 2 taken 3152228 times.
✗ Branch 3 not taken.
3240439 if(index<=0 || index>=WAV_COUNT)
9229 88211 return;
9230
9231
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3152215 times.
3152228 if(sfx_voice[index]!=-1)
9232 {
9233 13 deallocate_voice(sfx_voice[index]);
9234 13 sfx_voice[index]=-1;
9235 13 }
9236 3240439 }
9237
9238 // Stops SFX played by Hero's item of the given family
9239 6389 void stop_item_sfx(int32_t family)
9240 {
9241 6389 int32_t id=current_item_id(family);
9242
9243
2/2
✓ Branch 0 taken 6123 times.
✓ Branch 1 taken 266 times.
6389 if(id<0)
9244 6123 return;
9245
9246 266 stop_sfx(itemsbuf[id].usesound);
9247 6389 }
9248
9249 1066 void kill_sfx()
9250 {
9251
2/2
✓ Branch 0 taken 272896 times.
✓ Branch 1 taken 1066 times.
273962 for(int32_t i=0; i<WAV_COUNT; i++)
9252
2/2
✓ Branch 0 taken 272890 times.
✓ Branch 1 taken 6 times.
272902 if(sfx_voice[i]!=-1)
9253 {
9254 6 deallocate_voice(sfx_voice[i]);
9255 6 sfx_voice[i]=-1;
9256 6 }
9257 1066 }
9258
9259 340232 int32_t pan(int32_t x)
9260 {
9261
1/4
✓ Branch 0 taken 340232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
340232 switch(pan_style)
9262 {
9263 case 0:
9264 return 128;
9265
9266 case 1:
9267 340232 return vbound((x>>1)+68,0,255);
9268
9269 case 2:
9270 return vbound(((x*3)>>2)+36,0,255);
9271 }
9272
9273 return vbound(x,0,255);
9274 340232 }
9275
9276 /*******************************/
9277 /******* Input Handlers ********/
9278 /*******************************/
9279
9280 9374429 bool joybtn(int32_t b)
9281 {
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9374429 times.
9374429 if(b == 0)
9283 return false;
9284
9285 9374429 return joy[joystick_index].button[b-1].b !=0;
9286 9374429 }
9287
9288 const char* joybtn_name(int32_t b)
9289 {
9290 if(b == 0)
9291 return "";
9292
9293 return joy[joystick_index].button[b-1].name;
9294 }
9295
9296 int32_t next_press_key()
9297 {
9298 return readkey()>>8;
9299 }
9300
9301 int32_t next_press_btn()
9302 {
9303 clear_keybuf();
9304 /*bool b[joy[joystick_index].num_buttons+1];
9305
9306 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9307 b[i]=joybtn(i);*/
9308
9309 //first, we need to wait until they're pressing no buttons
9310 for(;;)
9311 {
9312 if(keypressed())
9313 {
9314 switch(readkey()>>8)
9315 {
9316 case KEY_ESC:
9317 return -1;
9318
9319 case KEY_SPACE:
9320 return 0;
9321 }
9322 }
9323
9324 poll_joystick();
9325 bool done = true;
9326
9327 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9328 {
9329 if(joybtn(i)) done = false;
9330 }
9331
9332 if(done) break;
9333 rest(1);
9334 }
9335
9336 //now, we need to wait for them to press any button
9337 for(;;)
9338 {
9339 if(keypressed())
9340 {
9341 switch(readkey()>>8)
9342 {
9343 case KEY_ESC:
9344 return -1;
9345
9346 case KEY_SPACE:
9347 return 0;
9348 }
9349 }
9350
9351 poll_joystick();
9352
9353 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9354 {
9355 if(joybtn(i)) return i;
9356 }
9357 rest(1);
9358 }
9359 }
9360
9361 83557451 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9362 {
9363
2/2
✓ Branch 0 taken 80560548 times.
✓ Branch 1 taken 2996903 times.
83557451 bool ret = btn && !flag;
9364
2/2
✓ Branch 0 taken 80190707 times.
✓ Branch 1 taken 3366744 times.
83557451 flag = rawbtn ? *rawbtn : btn;
9365
9366 83557451 return ret;
9367 }
9368 864 static bool rButtonPeek(bool btn, bool flag)
9369 {
9370
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 36 times.
864 if(!btn)
9371 {
9372 828 return false;
9373 }
9374
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9375 {
9376 9 return true;
9377 }
9378
9379 27 return false;
9380 864 }
9381
9382 // Updated only by keyboard/gamepad.
9383 // If in replay mode, this is set directly by the replay system.
9384 // This should never be read from directly - use control_state instead.
9385 bool raw_control_state[ZC_CONTROL_STATES];
9386
9387 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9388 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9389 // lasts until the next call to load_control_state.
9390 bool control_state[ZC_CONTROL_STATES];
9391 bool disable_control[ZC_CONTROL_STATES];
9392 bool drunk_toggle_state[11];
9393 bool disabledKeys[127];
9394 bool KeyInput[127];
9395 bool KeyPress[127];
9396
9397 bool key_current_frame[127];
9398 bool key_previous_frame[127];
9399
9400 static bool key_system[127];
9401 static bool key_system_previous[127];
9402 static bool key_system_press[127];
9403
9404 bool button_press[ZC_CONTROL_STATES];
9405 bool button_hold[ZC_CONTROL_STATES];
9406
9407 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9408 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9409 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9410 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9411 #define STICK_PRECISION 56 //define your own sensitivity
9412
9413 3358028 void load_control_state()
9414 {
9415
4/4
✓ Branch 0 taken 3358025 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 486824 times.
✓ Branch 3 taken 2871201 times.
3358028 if (!replay_is_active() || replay_get_version() >= 8)
9416 {
9417
2/2
✓ Branch 0 taken 8762886 times.
✓ Branch 1 taken 486827 times.
9249713 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9418 8762886 down_control_states[i] = raw_control_state[i];
9419 486827 }
9420
9421
1/2
✓ Branch 0 taken 3358028 times.
✗ Branch 1 not taken.
3358028 if (!replay_is_replaying())
9422 {
9423 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9424 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9425 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9426 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9427 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9428 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9429 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9430 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9431 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9432 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9433 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9434 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9435 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9436 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9437
9438 if(num_joysticks != 0)
9439 {
9440 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9441 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9442 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9443 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9444 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9445 }
9446 else
9447 {
9448 raw_control_state[14] = false;
9449 raw_control_state[15] = false;
9450 raw_control_state[16] = false;
9451 raw_control_state[17] = false;
9452 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9453 }
9454 }
9455
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3358025 times.
3358028 if (replay_is_active())
9456 {
9457
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 2342810 times.
3358025 if (replay_get_version() < 3)
9458 1015215 replay_poll();
9459
3/4
✓ Branch 0 taken 2342810 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 581435 times.
✓ Branch 3 taken 1761375 times.
2342810 else if (replay_is_replaying() && replay_get_version() < 6)
9460 1761375 replay_peek_input();
9461
3/4
✓ Branch 0 taken 581435 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94608 times.
✓ Branch 3 taken 486827 times.
581435 else if (replay_is_replaying() && replay_get_version() >= 8)
9462 486827 replay_peek_input();
9463 3358025 }
9464
9465
3/4
✓ Branch 0 taken 3358022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 486827 times.
✓ Branch 3 taken 2871195 times.
3358028 if (!replay_is_active() || replay_get_version() >= 8)
9466 486827 update_keys();
9467
9468 // Some test replay files were made before a serious input bug was fixed, so instead
9469 // of re-doing them or tossing them out, just check for that zplay version.
9470
3/4
✓ Branch 0 taken 3358022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 3236122 times.
3358022 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9471
2/2
✓ Branch 0 taken 3358022 times.
✓ Branch 1 taken 60444396 times.
63802418 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9472 {
9473 60444396 control_state[i] = raw_control_state[i];
9474
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 10957086 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
60444396 if (botched_input && !control_state[i])
9475 47077142 down_control_states[i] = false;
9476 60444396 }
9477
9478 3358022 button_press[0]=rButton(control_state[0],button_hold[0]);
9479 3358022 button_press[1]=rButton(control_state[1],button_hold[1]);
9480 3358022 button_press[2]=rButton(control_state[2],button_hold[2]);
9481 3358022 button_press[3]=rButton(control_state[3],button_hold[3]);
9482 3358022 button_press[4]=rButton(control_state[4],button_hold[4]);
9483 3358022 button_press[5]=rButton(control_state[5],button_hold[5]);
9484 3358022 button_press[6]=rButton(control_state[6],button_hold[6]);
9485 3358022 button_press[7]=rButton(control_state[7],button_hold[7]);
9486 3358022 button_press[8]=rButton(control_state[8],button_hold[8]);
9487 3358022 button_press[9]=rButton(control_state[9],button_hold[9]);
9488 3358022 button_press[10]=rButton(control_state[10],button_hold[10]);
9489 3358022 button_press[11]=rButton(control_state[11],button_hold[11]);
9490 3358022 button_press[12]=rButton(control_state[12],button_hold[12]);
9491 3358022 button_press[13]=rButton(control_state[13],button_hold[13]);
9492 3358022 button_press[14]=rButton(control_state[14],button_hold[14]);
9493 3358022 button_press[15]=rButton(control_state[15],button_hold[15]);
9494 3358022 button_press[16]=rButton(control_state[16],button_hold[16]);
9495 3358022 button_press[17]=rButton(control_state[17],button_hold[17]);
9496 3358022 }
9497
9498 // Returns true if any game key is pressed. This is needed because keypressed()
9499 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9500 17236930 bool zc_key_pressed()
9501 //may also need to use zc_getrawkey
9502 {
9503
7/10
✓ Branch 0 taken 13861503 times.
✓ Branch 1 taken 3375427 times.
✓ Branch 2 taken 3375427 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3375427 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2823032 times.
✓ Branch 7 taken 2823032 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 913084 times.
18150014 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9504
4/6
✓ Branch 0 taken 2823032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2823032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2110147 times.
✓ Branch 5 taken 2110147 times.
2823032 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9505
4/6
✓ Branch 0 taken 2110147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2110147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1333872 times.
✓ Branch 5 taken 1333872 times.
2110147 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9506
4/6
✓ Branch 0 taken 1333872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1333872 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1059651 times.
✓ Branch 5 taken 1059651 times.
1333872 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9507
1/2
✓ Branch 0 taken 1059651 times.
✗ Branch 1 not taken.
1059651 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9508
3/4
✓ Branch 0 taken 985743 times.
✓ Branch 1 taken 73908 times.
✓ Branch 2 taken 985743 times.
✗ Branch 3 not taken.
1059651 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9509
3/4
✓ Branch 0 taken 926322 times.
✓ Branch 1 taken 59421 times.
✓ Branch 2 taken 926322 times.
✗ Branch 3 not taken.
985743 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9510
3/4
✓ Branch 0 taken 921356 times.
✓ Branch 1 taken 4966 times.
✓ Branch 2 taken 921356 times.
✗ Branch 3 not taken.
926322 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9511
3/4
✓ Branch 0 taken 914287 times.
✓ Branch 1 taken 7069 times.
✓ Branch 2 taken 914287 times.
✗ Branch 3 not taken.
921356 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9512
3/4
✓ Branch 0 taken 913911 times.
✓ Branch 1 taken 376 times.
✓ Branch 2 taken 913911 times.
✗ Branch 3 not taken.
914287 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9513
3/4
✓ Branch 0 taken 913869 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 913869 times.
✗ Branch 3 not taken.
913911 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9514
3/4
✓ Branch 0 taken 913103 times.
✓ Branch 1 taken 766 times.
✓ Branch 2 taken 913103 times.
✗ Branch 3 not taken.
913869 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9515
2/4
✓ Branch 0 taken 913103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 913103 times.
✗ Branch 3 not taken.
913103 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9516
2/2
✓ Branch 0 taken 913084 times.
✓ Branch 1 taken 19 times.
913103 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9517 30977250 return true;
9518
9519 913084 return false;
9520 4167328 }
9521
9522 67096093 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9523 {
9524 67096093 bool ret = false, drunkstate = false, rawret = false;
9525 67096093 bool* flag = &down_control_states[btn];
9526
2/7
✓ Branch 0 taken 62924160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4171933 times.
67096093 switch(btn)
9527 {
9528 case btnF12:
9529 ret = zc_getkey(KEY_F12, ignoreDisable);
9530 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9531 eatEntirely = false;
9532 break;
9533 case btnF11:
9534 ret = zc_getkey(KEY_F11, ignoreDisable);
9535 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9536 eatEntirely = false;
9537 break;
9538 case btnF5:
9539 ret = zc_getkey(KEY_F5, ignoreDisable);
9540 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9541 eatEntirely = false;
9542 break;
9543 case btnQ:
9544 ret = zc_getkey(KEY_Q, ignoreDisable);
9545 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9546 eatEntirely = false;
9547 break;
9548 case btnI:
9549 ret = zc_getkey(KEY_I, ignoreDisable);
9550 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9551 eatEntirely = false;
9552 break;
9553 case btnM:
9554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4171933 times.
4171933 if(FFCore.kb_typing_mode) return false;
9555 4171933 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9556 4171933 eatEntirely = false;
9557 4171933 break;
9558 default: //control_state[] index
9559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62924160 times.
62924160 if(FFCore.kb_typing_mode) return false;
9560
5/6
✓ Branch 0 taken 62779194 times.
✓ Branch 1 taken 144966 times.
✓ Branch 2 taken 1875887 times.
✓ Branch 3 taken 60903307 times.
✓ Branch 4 taken 1875887 times.
✗ Branch 5 not taken.
62924160 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9561
2/2
✓ Branch 0 taken 3440581 times.
✓ Branch 1 taken 59483579 times.
62924160 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9562
4/4
✓ Branch 0 taken 56401289 times.
✓ Branch 1 taken 6522871 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 6521795 times.
69447031 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9563 62924160 rawret = raw_control_state[btn];
9564 62924160 }
9565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67096093 times.
67096093 assert(flag);
9566
2/2
✓ Branch 0 taken 43982174 times.
✓ Branch 1 taken 23113919 times.
67096093 if(press)
9567 {
9568
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 23113055 times.
23113919 if(peek)
9569 864 ret = rButtonPeek(ret, *flag);
9570
3/4
✓ Branch 0 taken 23113055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3366744 times.
✓ Branch 3 taken 19746311 times.
23113055 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9571 3366744 else ret = rButton(ret, *flag, &rawret);
9572 23113919 }
9573
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67096093 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67096093 if(eatEntirely && ret) control_state[btn] = false;
9574
3/4
✓ Branch 0 taken 51574004 times.
✓ Branch 1 taken 15522089 times.
✓ Branch 2 taken 51574004 times.
✗ Branch 3 not taken.
67096093 if(drunk && drunkstate) ret = !ret;
9575 67096093 return ret;
9576 67096093 }
9577
9578 367681 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9579 {
9580 367681 byte ret = 0;
9581
2/2
✓ Branch 0 taken 366817 times.
✓ Branch 1 taken 864 times.
367681 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9582
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9583
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9584
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9585
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9586
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9587
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9588
1/2
✓ Branch 0 taken 367681 times.
✗ Branch 1 not taken.
367681 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9589 367681 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9590 }
9591
9592 byte checkIntBtnVal(byte intbtn, byte vals)
9593 {
9594 return intbtn&vals;
9595 }
9596
9597 691628 bool Up()
9598 {
9599 691628 return getInput(btnUp);
9600 }
9601 20680 bool Down()
9602 {
9603 20680 return getInput(btnDown);
9604 }
9605 28679 bool Left()
9606 {
9607 28679 return getInput(btnLeft);
9608 }
9609 31135 bool Right()
9610 {
9611 31135 return getInput(btnRight);
9612 }
9613 36798 bool cAbtn()
9614 {
9615 36798 return getInput(btnA);
9616 }
9617 660519 bool cBbtn()
9618 {
9619 660519 return getInput(btnB);
9620 }
9621 bool cSbtn()
9622 {
9623 return getInput(btnS);
9624 }
9625 6440 bool cLbtn()
9626 {
9627 6440 return getInput(btnL);
9628 }
9629 6440 bool cRbtn()
9630 {
9631 6440 return getInput(btnR);
9632 }
9633 bool cPbtn()
9634 {
9635 return getInput(btnP);
9636 }
9637 bool cEx1btn()
9638 {
9639 return getInput(btnEx1);
9640 }
9641 bool cEx2btn()
9642 {
9643 return getInput(btnEx2);
9644 }
9645 bool cEx3btn()
9646 {
9647 return getInput(btnEx3);
9648 }
9649 bool cEx4btn()
9650 {
9651 return getInput(btnEx4);
9652 }
9653 bool AxisUp()
9654 {
9655 return getInput(btnAxisUp);
9656 }
9657 bool AxisDown()
9658 {
9659 return getInput(btnAxisDown);
9660 }
9661 bool AxisLeft()
9662 {
9663 return getInput(btnAxisLeft);
9664 }
9665 bool AxisRight()
9666 {
9667 return getInput(btnAxisRight);
9668 }
9669
9670 bool cMbtn()
9671 {
9672 return getInput(btnM);
9673 }
9674 bool cF12()
9675 {
9676 return getInput(btnF12);
9677 }
9678 bool cF11()
9679 {
9680 return getInput(btnF11);
9681 }
9682 bool cF5()
9683 {
9684 return getInput(btnF5);
9685 }
9686 bool cQ()
9687 {
9688 return getInput(btnQ);
9689 }
9690 bool cI()
9691 {
9692 return getInput(btnI);
9693 }
9694
9695 66630 bool rUp()
9696 {
9697 66630 return getInput(btnUp, true);
9698 }
9699 66586 bool rDown()
9700 {
9701 66586 return getInput(btnDown, true);
9702 }
9703 66574 bool rLeft()
9704 {
9705 66574 return getInput(btnLeft, true);
9706 }
9707 66168 bool rRight()
9708 {
9709 66168 return getInput(btnRight, true);
9710 }
9711 352 bool rAbtn()
9712 {
9713 352 return getInput(btnA, true);
9714 }
9715 66982 bool rBbtn()
9716 {
9717 66982 return getInput(btnB, true);
9718 }
9719 3289763 bool rSbtn()
9720 {
9721 3289763 return getInput(btnS, true);
9722 }
9723 4167328 bool rMbtn()
9724 {
9725 4167328 return getInput(btnM, true);
9726 }
9727 66017 bool rLbtn()
9728 {
9729 66017 return getInput(btnL, true);
9730 }
9731 66014 bool rRbtn()
9732 {
9733 66014 return getInput(btnR, true);
9734 }
9735 3228682 bool rPbtn()
9736 {
9737 3228682 return getInput(btnP, true);
9738 }
9739 bool rEx1btn()
9740 {
9741 return getInput(btnEx1, true);
9742 }
9743 bool rEx2btn()
9744 {
9745 return getInput(btnEx2, true);
9746 }
9747 66574 bool rEx3btn()
9748 {
9749 66574 return getInput(btnEx3, true);
9750 }
9751 66574 bool rEx4btn()
9752 {
9753 66574 return getInput(btnEx4, true);
9754 }
9755 bool rAxisUp()
9756 {
9757 return getInput(btnAxisUp, true);
9758 }
9759 bool rAxisDown()
9760 {
9761 return getInput(btnAxisDown, true);
9762 }
9763 bool rAxisLeft()
9764 {
9765 return getInput(btnAxisLeft, true);
9766 }
9767 bool rAxisRight()
9768 {
9769 return getInput(btnAxisRight, true);
9770 }
9771
9772 bool rF11()
9773 {
9774 return getInput(btnF11, true);
9775 }
9776 bool rQ()
9777 {
9778 return getInput(btnQ, true);
9779 }
9780 bool rI()
9781 {
9782 return getInput(btnI, true);
9783 }
9784
9785 8441194 bool DrunkUp()
9786 {
9787 8441194 return getInput(btnUp, false, true);
9788 }
9789 7872483 bool DrunkDown()
9790 {
9791 7872483 return getInput(btnDown, false, true);
9792 }
9793 5234585 bool DrunkLeft()
9794 {
9795 5234585 return getInput(btnLeft, false, true);
9796 }
9797 4635468 bool DrunkRight()
9798 {
9799 4635468 return getInput(btnRight, false, true);
9800 }
9801 3688850 bool DrunkcAbtn()
9802 {
9803 3688850 return getInput(btnA, false, true);
9804 }
9805 3577428 bool DrunkcBbtn()
9806 {
9807 3577428 return getInput(btnB, false, true);
9808 }
9809 3221936 bool DrunkcEx1btn()
9810 {
9811 3221936 return getInput(btnEx1, false, true);
9812 }
9813 3221956 bool DrunkcEx2btn()
9814 {
9815 3221956 return getInput(btnEx2, false, true);
9816 }
9817 bool DrunkcSbtn()
9818 {
9819 return getInput(btnS, false, true);
9820 }
9821 bool DrunkcMbtn()
9822 {
9823 return getInput(btnM, false, true);
9824 }
9825 bool DrunkcLbtn()
9826 {
9827 return getInput(btnL, false, true);
9828 }
9829 bool DrunkcRbtn()
9830 {
9831 return getInput(btnR, false, true);
9832 }
9833 bool DrunkcPbtn()
9834 {
9835 return getInput(btnP, false, true);
9836 }
9837
9838 bool DrunkrUp()
9839 {
9840 return getInput(btnUp, true, true);
9841 }
9842 bool DrunkrDown()
9843 {
9844 return getInput(btnDown, true, true);
9845 }
9846 bool DrunkrLeft()
9847 {
9848 return getInput(btnLeft, true, true);
9849 }
9850 bool DrunkrRight()
9851 {
9852 return getInput(btnRight, true, true);
9853 }
9854 2636995 bool DrunkrAbtn()
9855 {
9856 2636995 return getInput(btnA, true, true);
9857 }
9858 2627144 bool DrunkrBbtn()
9859 {
9860 2627144 return getInput(btnB, true, true);
9861 }
9862 71669 bool DrunkrEx1btn()
9863 {
9864 71669 return getInput(btnEx1, true, true);
9865 }
9866 71662 bool DrunkrEx2btn()
9867 {
9868 71662 return getInput(btnEx2, true, true);
9869 }
9870 bool DrunkrEx3btn()
9871 {
9872 return getInput(btnEx3, true, true);
9873 }
9874 bool DrunkrEx4btn()
9875 {
9876 return getInput(btnEx4, true, true);
9877 }
9878 bool DrunkrSbtn()
9879 {
9880 return getInput(btnS, true, true);
9881 }
9882 bool DrunkrMbtn()
9883 {
9884 return getInput(btnM, true, true);
9885 }
9886 3136637 bool DrunkrLbtn()
9887 {
9888 3136637 return getInput(btnL, true, true);
9889 }
9890 3135133 bool DrunkrRbtn()
9891 {
9892 3135133 return getInput(btnR, true, true);
9893 }
9894 bool DrunkrPbtn()
9895 {
9896 return getInput(btnP, true, true);
9897 }
9898
9899 4605 void eat_buttons()
9900 {
9901 4605 getInput(btnA, true, false, true);
9902 4605 getInput(btnB, true, false, true);
9903 4605 getInput(btnS, true, false, true);
9904 4605 getInput(btnM, true, false, true);
9905 4605 getInput(btnL, true, false, true);
9906 4605 getInput(btnR, true, false, true);
9907 4605 getInput(btnP, true, false, true);
9908 4605 getInput(btnEx1, true, false, true);
9909 4605 getInput(btnEx2, true, false, true);
9910 4605 getInput(btnEx3, true, false, true);
9911 4605 getInput(btnEx4, true, false, true);
9912 4605 }
9913
9914 // Is true for the _first frame_ of a key press.
9915 // But! it is possible that a script manually sets the value of KeyPress,
9916 // in which case it will be restored to the "true" value based on `key_current_frame`
9917 // and `key_previous_frame` on the next frame.
9918 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9919 {
9920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9922 {
9923 case KEY_F7:
9924 case KEY_F8:
9925 case KEY_F9:
9926 return KeyPress[k];
9927
9928 default:
9929
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9930 }
9931 14 }
9932
9933 // Is true for _every frame_ a key is held down.
9934 // But! it is possible that a script manually sets the value of KeyInput,
9935 // in which case it will be restored to the "true" value based on `key_current_frame`
9936 // on the next frame.
9937 bool zc_getkey(int32_t k, bool ignoreDisable)
9938 {
9939 if(ignoreDisable) return KeyInput[k];
9940 switch(k)
9941 {
9942 case KEY_F7:
9943 case KEY_F8:
9944 case KEY_F9:
9945 return KeyInput[k];
9946
9947 default:
9948 return KeyInput[k] && !disabledKeys[k];
9949 }
9950 }
9951
9952 // Reads (and then clears) the current frame key state directly.
9953 // Scripts can also modify `key_current_frame`.
9954 27616672 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9955 {
9956
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 27616671 times.
27616672 if(zc_getrawkey(k, ignoreDisable))
9957 {
9958 1 _key[k]=key[k]=key_current_frame[k]=0;
9959 1 return true;
9960 }
9961 27616671 _key[k]=key[k]=key_current_frame[k]=0;
9962 27616671 return false;
9963 27616672 }
9964
9965 // Reads the current frame key state directly.
9966 // Scripts can also modify `key_current_frame`.
9967 54059756 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9968 {
9969
2/2
✓ Branch 0 taken 22275796 times.
✓ Branch 1 taken 31783960 times.
54059756 if(ignoreDisable) return key_current_frame[k];
9970
2/2
✓ Branch 0 taken 13808302 times.
✓ Branch 1 taken 17975658 times.
31783960 switch(k)
9971 {
9972 case KEY_F7:
9973 case KEY_F8:
9974 case KEY_F9:
9975 13808302 return key_current_frame[k];
9976
9977 default:
9978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17975658 times.
17975658 return key_current_frame[k] && !disabledKeys[k];
9979 }
9980 54059756 }
9981
9982 // Only used for a handful of keys, like tilde and Function keys.
9983 // This state is never read within the game.
9984 // It exists so that all keyboard input still functions during replay,
9985 // without inadvertently doing things like toggling throttling if the player
9986 // presses ~
9987 8219246 bool zc_get_system_key(int32_t k)
9988 {
9989 8219246 return key_system[k];
9990 }
9991
9992 // True for the _first_ frame of a key press.
9993 45840608 bool zc_read_system_key(int32_t k)
9994 {
9995 45840608 return key_system_press[k];
9996 }
9997
9998 529250656 bool is_system_key(int32_t k)
9999 {
10000
2/2
✓ Branch 0 taken 491744704 times.
✓ Branch 1 taken 37505952 times.
529250656 switch (k)
10001 {
10002 case KEY_BACKQUOTE:
10003 case KEY_CLOSEBRACE:
10004 case KEY_END:
10005 case KEY_HOME:
10006 case KEY_OPENBRACE:
10007 case KEY_PGDN:
10008 case KEY_PGUP:
10009 case KEY_TAB:
10010 case KEY_TILDE:
10011 37505952 return true;
10012 }
10013 491744704 return is_Fkey(k);
10014 529250656 }
10015
10016 4167328 void update_system_keys()
10017 {
10018 4167328 poll_keyboard();
10019
2/2
✓ Branch 0 taken 529250656 times.
✓ Branch 1 taken 4167328 times.
533417984 for (int32_t q = 0; q < 127; ++q)
10020 {
10021
2/2
✓ Branch 0 taken 87513888 times.
✓ Branch 1 taken 441736768 times.
529250656 if (!is_system_key(q))
10022 441736768 continue;
10023
10024 87513888 key_system[q] = key[q];
10025
1/2
✓ Branch 0 taken 87513888 times.
✗ Branch 1 not taken.
87513888 key_system_press[q] = key_system[q] && !key_system_previous[q];
10026 87513888 key_system_previous[q] = key_system[q];
10027 87513888 }
10028 4167328 }
10029
10030 4596441 void update_keys()
10031 {
10032
1/2
✓ Branch 0 taken 4596441 times.
✗ Branch 1 not taken.
4596441 if (!replay_is_replaying())
10033 poll_keyboard();
10034
10035
2/2
✓ Branch 0 taken 4596441 times.
✓ Branch 1 taken 583748007 times.
588344448 for (int32_t q = 0; q < 127; ++q)
10036 {
10037 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10038
1/2
✓ Branch 0 taken 583748007 times.
✗ Branch 1 not taken.
583748007 if (!replay_is_replaying())
10039 key_current_frame[q] = key[q];
10040
10041
2/2
✓ Branch 0 taken 579797837 times.
✓ Branch 1 taken 3950170 times.
583748007 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10042 583748007 KeyInput[q] = key_current_frame[q];
10043 583748007 key_previous_frame[q] = key_current_frame[q];
10044 583748007 }
10045 4596441 }
10046
10047 bool zc_disablekey(int32_t k, bool val)
10048 {
10049 switch(k)
10050 {
10051 case KEY_F7:
10052 case KEY_F8:
10053 case KEY_F9:
10054 return false;
10055
10056 default:
10057 disabledKeys[k] = val;
10058 return true;
10059 }
10060 }
10061
10062 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10063 {
10064 timer=timer;
10065 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10066 }
10067
10068 // these are here so that copy_dialog won't choke when compiling zelda
10069 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10070 {
10071 return D_O_K;
10072 }
10073
10074 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10075 {
10076 return D_O_K;
10077 }
10078
10079 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10080 {
10081 return D_O_K;
10082 }
10083
10084 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10085 {
10086 return D_O_K;
10087 }
10088
10089 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10090 {
10091 return D_O_K;
10092 }
10093
10094 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10095 {
10096 return D_O_K;
10097 }
10098
10099 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10100 {
10101 return D_O_K;
10102 }
10103
10104 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10105 {
10106 return D_O_K;
10107 }
10108
10109 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10110 {
10111 return D_O_K;
10112 }
10113
10114 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10115 {
10116 return D_O_K;
10117 }
10118
10119 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10120 {
10121 return D_O_K;
10122 }
10123
10124 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10125 {
10126 return D_O_K;
10127 }
10128
10129 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10130 {
10131 return D_O_K;
10132 }
10133
10134 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10135 {
10136 return D_O_K;
10137 }
10138
10139 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10140 {
10141 return D_O_K;
10142 }
10143
10144 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10145 {
10146 return D_O_K;
10147 }
10148
10149 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10150 {
10151 return D_O_K;
10152 }
10153
10154 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10155 {
10156 return D_O_K;
10157 }
10158
10159 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10160 {
10161 return D_O_K;
10162 }
10163
10164 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10165 {
10166 return D_O_K;
10167 }
10168
10169 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10170 {
10171 return D_O_K;
10172 }
10173
10174 /*** end of zc_sys.cc ***/
10175
10176